Skip to content

Commit 0562064

Browse files
Correctly consider depth when visiting WF goals
1 parent 93ee07c commit 0562064

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

compiler/rustc_trait_selection/src/solve/fulfill.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,19 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
520520
if let Some(ty::PredicateKind::AliasRelate(lhs, rhs, _)) = pred_kind.no_bound_vars() {
521521
if let Some(obligation) = goal
522522
.infcx()
523-
.visit_proof_tree(
523+
.visit_proof_tree_at_depth(
524524
goal.goal().with(goal.infcx().tcx, ty::ClauseKind::WellFormed(lhs.into())),
525+
goal.depth() + 1,
525526
self,
526527
)
527528
.break_value()
528529
{
529530
return ControlFlow::Break(obligation);
530531
} else if let Some(obligation) = goal
531532
.infcx()
532-
.visit_proof_tree(
533+
.visit_proof_tree_at_depth(
533534
goal.goal().with(goal.infcx().tcx, ty::ClauseKind::WellFormed(rhs.into())),
535+
goal.depth() + 1,
534536
self,
535537
)
536538
.break_value()

compiler/rustc_trait_selection/src/solve/inspect/analyse.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
278278
self.source
279279
}
280280

281+
pub fn depth(&self) -> usize {
282+
self.depth
283+
}
284+
281285
fn candidates_recur(
282286
&'a self,
283287
candidates: &mut Vec<InspectCandidate<'a, 'tcx>>,
@@ -435,9 +439,18 @@ impl<'tcx> InferCtxt<'tcx> {
435439
&self,
436440
goal: Goal<'tcx, ty::Predicate<'tcx>>,
437441
visitor: &mut V,
442+
) -> V::Result {
443+
self.visit_proof_tree_at_depth(goal, 0, visitor)
444+
}
445+
446+
fn visit_proof_tree_at_depth<V: ProofTreeVisitor<'tcx>>(
447+
&self,
448+
goal: Goal<'tcx, ty::Predicate<'tcx>>,
449+
depth: usize,
450+
visitor: &mut V,
438451
) -> V::Result {
439452
let (_, proof_tree) = self.evaluate_root_goal(goal, GenerateProofTree::Yes);
440453
let proof_tree = proof_tree.unwrap();
441-
visitor.visit_goal(&InspectGoal::new(self, 0, proof_tree, None, GoalSource::Misc))
454+
visitor.visit_goal(&InspectGoal::new(self, depth, proof_tree, None, GoalSource::Misc))
442455
}
443456
}

0 commit comments

Comments
 (0)