Skip to content

Commit f6bfe28

Browse files
Super visitor
1 parent 5de29df commit f6bfe28

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

compiler/rustc_trait_selection/src/solve/fulfill.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ fn fulfillment_error_for_no_solution<'tcx>(
219219
}
220220
ty::PredicateKind::Subtype(pred) => {
221221
let (a, b) = infcx.enter_forall_and_leak_universe(
222-
root_obligation.predicate.kind().rebind((pred.a, pred.b)),
222+
obligation.predicate.kind().rebind((pred.a, pred.b)),
223223
);
224224
let expected_found = ExpectedFound::new(true, a, b);
225225
FulfillmentErrorCode::SubtypeError(expected_found, TypeError::Sorts(expected_found))
226226
}
227227
ty::PredicateKind::Coerce(pred) => {
228228
let (a, b) = infcx.enter_forall_and_leak_universe(
229-
root_obligation.predicate.kind().rebind((pred.a, pred.b)),
229+
obligation.predicate.kind().rebind((pred.a, pred.b)),
230230
);
231231
let expected_found = ExpectedFound::new(false, a, b);
232232
FulfillmentErrorCode::SubtypeError(expected_found, TypeError::Sorts(expected_found))
@@ -298,13 +298,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
298298
}
299299

300300
fn visit_goal(&mut self, goal: &super::inspect::InspectGoal<'_, 'tcx>) -> Self::Result {
301-
let candidates = goal.candidates();
302301
// FIXME: Throw out candidates that have no failing WC and >1 failing misc goal.
303-
304-
// HACK:
305-
if self.obligation.recursion_depth > 3 {
306-
return ControlFlow::Break(self.obligation.clone());
307-
}
302+
let candidates = goal.candidates();
308303

309304
let [candidate] = candidates.as_slice() else {
310305
return ControlFlow::Break(self.obligation.clone());
@@ -376,7 +371,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
376371
recursion_depth: self_.obligation.recursion_depth + 1,
377372
}
378373
},
379-
|self_| self_.visit_goal(&nested_goal),
374+
|self_| nested_goal.visit_with(self),
380375
)?;
381376
}
382377

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

+8
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
360360
source,
361361
}
362362
}
363+
364+
pub(crate) fn visit_with<V: ProofTreeVisitor<'tcx>>(&self, visitor: &mut V) -> V::Result {
365+
if self.goal.depth < visitor.config().max_depth {
366+
try_visit!(visitor.visit_goal(self));
367+
}
368+
369+
V::Result::output()
370+
}
363371
}
364372

365373
/// The public API to interact with proof trees.

0 commit comments

Comments
 (0)