Skip to content

Commit 51b1b50

Browse files
committed
rework search graph cycle handling
1 parent 80c0919 commit 51b1b50

File tree

6 files changed

+181
-134
lines changed

6 files changed

+181
-134
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ where
180180
span: I::Span,
181181
) -> (Result<(HasChanged, Certainty), NoSolution>, Option<inspect::GoalEvaluation<I>>) {
182182
EvalCtxt::enter_root(self, self.cx().recursion_limit(), generate_proof_tree, span, |ecx| {
183-
ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal)
183+
ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Root, goal)
184184
})
185185
}
186186

@@ -191,7 +191,7 @@ where
191191
) -> bool {
192192
self.probe(|| {
193193
EvalCtxt::enter_root(self, root_depth, GenerateProofTree::No, I::Span::dummy(), |ecx| {
194-
ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal)
194+
ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Root, goal)
195195
})
196196
.0
197197
})
@@ -212,7 +212,7 @@ where
212212
self.cx().recursion_limit(),
213213
generate_proof_tree,
214214
I::Span::dummy(),
215-
|ecx| ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Misc, goal),
215+
|ecx| ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Root, goal),
216216
)
217217
}
218218
}
@@ -340,6 +340,7 @@ where
340340
cx: I,
341341
search_graph: &'a mut SearchGraph<D>,
342342
canonical_input: CanonicalInput<I>,
343+
source: GoalSource,
343344
goal_evaluation: &mut ProofTreeBuilder<D>,
344345
) -> QueryResult<I> {
345346
let mut canonical_goal_evaluation =
@@ -352,6 +353,7 @@ where
352353
search_graph.with_new_goal(
353354
cx,
354355
canonical_input,
356+
source,
355357
&mut canonical_goal_evaluation,
356358
|search_graph, canonical_goal_evaluation| {
357359
EvalCtxt::enter_canonical(
@@ -395,12 +397,10 @@ where
395397
/// `NormalizesTo` is only used by `AliasRelate`, all other callsites
396398
/// should use [`EvalCtxt::evaluate_goal`] which discards that empty
397399
/// storage.
398-
// FIXME(-Znext-solver=coinduction): `_source` is currently unused but will
399-
// be necessary once we implement the new coinduction approach.
400400
pub(super) fn evaluate_goal_raw(
401401
&mut self,
402402
goal_evaluation_kind: GoalEvaluationKind,
403-
_source: GoalSource,
403+
source: GoalSource,
404404
goal: Goal<I, I::Predicate>,
405405
) -> Result<(NestedNormalizationGoals<I>, HasChanged, Certainty), NoSolution> {
406406
let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
@@ -410,6 +410,7 @@ where
410410
self.cx(),
411411
self.search_graph,
412412
canonical_goal,
413+
source,
413414
&mut goal_evaluation,
414415
);
415416
let response = match canonical_response {

compiler/rustc_next_trait_solver/src/solve/search_graph.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ where
9494
let certainty = from_result.unwrap().value.certainty;
9595
response_no_constraints(cx, for_input, certainty)
9696
}
97-
98-
fn step_is_coinductive(cx: I, input: CanonicalInput<I>) -> bool {
99-
input.canonical.value.goal.predicate.is_coinductive(cx)
100-
}
10197
}
10298

10399
fn response_no_constraints<I: Interner>(

compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
354354

355355
let obligation;
356356
match (child_mode, nested_goal.source()) {
357+
(_, GoalSource::Root) => unreachable!(),
357358
(ChildMode::Trait(_) | ChildMode::Host(_), GoalSource::Misc) => {
358359
continue;
359360
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,6 @@ impl<'tcx> InferCtxt<'tcx> {
446446
visitor.span(),
447447
);
448448
let proof_tree = proof_tree.unwrap();
449-
visitor.visit_goal(&InspectGoal::new(self, depth, proof_tree, None, GoalSource::Misc))
449+
visitor.visit_goal(&InspectGoal::new(self, depth, proof_tree, None, GoalSource::Root))
450450
}
451451
}

0 commit comments

Comments
 (0)