Skip to content

Commit ecd65f8

Browse files
committed
evaluate_goal: accept different inputs
1 parent 75da5c4 commit ecd65f8

File tree

2 files changed

+6
-7
lines changed
  • compiler
    • rustc_next_trait_solver/src/solve/eval_ctxt
    • rustc_type_ir/src/search_graph

2 files changed

+6
-7
lines changed

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ where
430430
canonical_input,
431431
step_kind_from_parent,
432432
&mut canonical_goal_evaluation,
433-
|search_graph, canonical_goal_evaluation| {
433+
|search_graph, cx, canonical_input, canonical_goal_evaluation| {
434434
EvalCtxt::enter_canonical(
435435
cx,
436436
search_graph,

compiler/rustc_type_ir/src/search_graph/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
597597
input: X::Input,
598598
step_kind_from_parent: PathKind,
599599
inspect: &mut D::ProofTreeBuilder,
600-
mut evaluate_goal: impl FnMut(&mut Self, &mut D::ProofTreeBuilder) -> X::Result,
600+
evaluate_goal: impl Fn(&mut Self, X, X::Input, &mut D::ProofTreeBuilder) -> X::Result + Copy,
601601
) -> X::Result {
602602
let Some(available_depth) =
603603
AvailableDepth::allowed_depth_for_nested::<D>(self.root_depth, &self.stack)
@@ -665,9 +665,8 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
665665
// not tracked by the cache key and from outside of this anon task, it
666666
// must not be added to the global cache. Notably, this is the case for
667667
// trait solver cycles participants.
668-
let (evaluation_result, dep_node) = cx.with_cached_task(|| {
669-
self.evaluate_goal_in_task(cx, input, inspect, &mut evaluate_goal)
670-
});
668+
let (evaluation_result, dep_node) =
669+
cx.with_cached_task(|| self.evaluate_goal_in_task(cx, input, inspect, evaluate_goal));
671670

672671
// We've finished computing the goal and have popped it from the stack,
673672
// lazily update its parent goal.
@@ -1065,7 +1064,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
10651064
cx: X,
10661065
input: X::Input,
10671066
inspect: &mut D::ProofTreeBuilder,
1068-
mut evaluate_goal: impl FnMut(&mut Self, &mut D::ProofTreeBuilder) -> X::Result,
1067+
evaluate_goal: impl Fn(&mut Self, X, X::Input, &mut D::ProofTreeBuilder) -> X::Result + Copy,
10691068
) -> EvaluationResult<X> {
10701069
// We reset `encountered_overflow` each time we rerun this goal
10711070
// but need to make sure we currently propagate it to the global
@@ -1074,7 +1073,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
10741073
let mut encountered_overflow = false;
10751074
let mut i = 0;
10761075
loop {
1077-
let result = evaluate_goal(self, inspect);
1076+
let result = evaluate_goal(self, cx, input, inspect);
10781077
let stack_entry = self.stack.pop();
10791078
encountered_overflow |= stack_entry.encountered_overflow;
10801079
debug_assert_eq!(stack_entry.input, input);

0 commit comments

Comments
 (0)