Skip to content

Commit 74ee70c

Browse files
committed
Avoid query in cases where it will probably be region-dependent
1 parent 121faca commit 74ee70c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/rustc_middle/src/ty/fold.rs

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
116116
fn has_free_regions(&self) -> bool {
117117
self.has_type_flags(TypeFlags::HAS_FREE_REGIONS)
118118
}
119+
fn has_free_local_regions(&self) -> bool {
120+
self.has_type_flags(TypeFlags::HAS_FREE_LOCAL_REGIONS)
121+
}
119122

120123
fn has_erased_regions(&self) -> bool {
121124
self.has_type_flags(TypeFlags::HAS_RE_ERASED)

compiler/rustc_trait_selection/src/traits/fulfill.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
619619
stalled_on: &mut Vec<TyOrConstInferVar<'tcx>>,
620620
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
621621
let infcx = self.selcx.infcx();
622-
if !obligation.predicate.needs_infer() {
622+
if !obligation.predicate.needs_infer() && !obligation.predicate.has_free_local_regions() {
623623
// no type variables present, can use evaluation for better caching.
624624
// FIXME: consider caching errors too.
625625
if infcx.predicate_must_hold_considering_regions(obligation) {
@@ -628,6 +628,8 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
628628
obligation.recursion_depth
629629
);
630630
return ProcessResult::Changed(vec![]);
631+
} else {
632+
debug!("Eager eval failed: {:?}", obligation);
631633
}
632634
}
633635

0 commit comments

Comments
 (0)