Skip to content

Commit 3e60047

Browse files
Auto merge of #142085 - compiler-errors:perf-self-obl, r=<try>
[perf] test
2 parents c360e21 + 54b62fc commit 3e60047

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_infer::traits::{self, ObligationCause, PredicateObligations};
44
use rustc_middle::traits::solve::GoalSource;
55
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
66
use rustc_span::Span;
7+
use rustc_trait_selection::solve::Certainty;
78
use rustc_trait_selection::solve::inspect::{
89
InspectConfig, InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor,
910
};
@@ -117,6 +118,17 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for NestedObligationsForSelfTy<'a, 'tcx> {
117118
}
118119

119120
fn visit_goal(&mut self, inspect_goal: &InspectGoal<'_, 'tcx>) {
121+
// No need to walk into goal subtrees that certainly hold, since they
122+
// wouldn't then be stalled on an infer var.
123+
if inspect_goal.result() == Ok(Certainty::Yes)
124+
&& !matches!(
125+
inspect_goal.goal().predicate.kind().skip_binder(),
126+
ty::PredicateKind::NormalizesTo(_)
127+
)
128+
{
129+
return;
130+
}
131+
120132
let tcx = self.fcx.tcx;
121133
let goal = inspect_goal.goal();
122134
if self.fcx.predicate_has_self_ty(goal.predicate, self.self_ty)

0 commit comments

Comments
 (0)