diff options
| author | Michael Goulet <michael@errs.io> | 2024-06-14 17:19:47 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-06-14 17:19:58 -0400 |
| commit | 0562064959f478e18ba840854a8d73503a1cf9f0 (patch) | |
| tree | 1b8bd8bd2f954720a91f5f750b9db20494781b6d | |
| parent | 93ee07c75603ad5492cf789eee89fd61ecc9d3ad (diff) | |
| download | rust-0562064959f478e18ba840854a8d73503a1cf9f0.tar.gz rust-0562064959f478e18ba840854a8d73503a1cf9f0.zip | |
Correctly consider depth when visiting WF goals
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/fulfill.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/inspect/analyse.rs | 15 |
2 files changed, 18 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 519a24f6975..3c01d1a65f5 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -520,8 +520,9 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { if let Some(ty::PredicateKind::AliasRelate(lhs, rhs, _)) = pred_kind.no_bound_vars() { if let Some(obligation) = goal .infcx() - .visit_proof_tree( + .visit_proof_tree_at_depth( goal.goal().with(goal.infcx().tcx, ty::ClauseKind::WellFormed(lhs.into())), + goal.depth() + 1, self, ) .break_value() @@ -529,8 +530,9 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { return ControlFlow::Break(obligation); } else if let Some(obligation) = goal .infcx() - .visit_proof_tree( + .visit_proof_tree_at_depth( goal.goal().with(goal.infcx().tcx, ty::ClauseKind::WellFormed(rhs.into())), + goal.depth() + 1, self, ) .break_value() diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index b9c98b6a2e9..464c188b6e3 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -278,6 +278,10 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> { self.source } + pub fn depth(&self) -> usize { + self.depth + } + fn candidates_recur( &'a self, candidates: &mut Vec<InspectCandidate<'a, 'tcx>>, @@ -436,8 +440,17 @@ impl<'tcx> InferCtxt<'tcx> { goal: Goal<'tcx, ty::Predicate<'tcx>>, visitor: &mut V, ) -> V::Result { + self.visit_proof_tree_at_depth(goal, 0, visitor) + } + + fn visit_proof_tree_at_depth<V: ProofTreeVisitor<'tcx>>( + &self, + goal: Goal<'tcx, ty::Predicate<'tcx>>, + depth: usize, + visitor: &mut V, + ) -> V::Result { let (_, proof_tree) = self.evaluate_root_goal(goal, GenerateProofTree::Yes); let proof_tree = proof_tree.unwrap(); - visitor.visit_goal(&InspectGoal::new(self, 0, proof_tree, None, GoalSource::Misc)) + visitor.visit_goal(&InspectGoal::new(self, depth, proof_tree, None, GoalSource::Misc)) } } |
