Skip to content

Commit

Permalink
Avoid query in cases where it will probably be region-dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Jun 30, 2021
1 parent 121faca commit 74ee70c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
fn has_free_regions(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_FREE_REGIONS)
}
fn has_free_local_regions(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_FREE_LOCAL_REGIONS)
}

fn has_erased_regions(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_RE_ERASED)
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
stalled_on: &mut Vec<TyOrConstInferVar<'tcx>>,
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
let infcx = self.selcx.infcx();
if !obligation.predicate.needs_infer() {
if !obligation.predicate.needs_infer() && !obligation.predicate.has_free_local_regions() {
// no type variables present, can use evaluation for better caching.
// FIXME: consider caching errors too.
if infcx.predicate_must_hold_considering_regions(obligation) {
Expand All @@ -628,6 +628,8 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
obligation.recursion_depth
);
return ProcessResult::Changed(vec![]);
} else {
debug!("Eager eval failed: {:?}", obligation);
}
}

Expand Down

0 comments on commit 74ee70c

Please sign in to comment.