Skip to content

Commit e81a865

Browse files
committed
rework search graph cycle handling
1 parent 45fee10 commit e81a865

File tree

3 files changed

+191
-136
lines changed

3 files changed

+191
-136
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
99
use rustc_type_ir::inherent::*;
1010
use rustc_type_ir::relate::Relate;
1111
use rustc_type_ir::relate::solver_relating::RelateExt;
12+
use rustc_type_ir::search_graph::PathKind;
1213
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
1314
use rustc_type_ir::{self as ty, CanonicalVarValues, InferCtxtLike, Interner, TypingMode};
1415
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
@@ -230,6 +231,13 @@ where
230231
self.is_normalizes_to_goal = true;
231232
}
232233

234+
pub(super) fn step_kind_for_source(&self, source: GoalSource) -> PathKind {
235+
match source {
236+
GoalSource::ImplWhereBound => PathKind::Coinductive,
237+
_ => PathKind::Inductive,
238+
}
239+
}
240+
233241
/// Creates a root evaluation context and search graph. This should only be
234242
/// used from outside of any evaluation, and other methods should be preferred
235243
/// over using this manually (such as [`SolverDelegateEvalExt::evaluate_root_goal`]).
@@ -340,6 +348,7 @@ where
340348
cx: I,
341349
search_graph: &'a mut SearchGraph<D>,
342350
canonical_input: CanonicalInput<I>,
351+
step_kind_from_parent: PathKind,
343352
goal_evaluation: &mut ProofTreeBuilder<D>,
344353
) -> QueryResult<I> {
345354
let mut canonical_goal_evaluation =
@@ -352,6 +361,7 @@ where
352361
search_graph.with_new_goal(
353362
cx,
354363
canonical_input,
364+
step_kind_from_parent,
355365
&mut canonical_goal_evaluation,
356366
|search_graph, canonical_goal_evaluation| {
357367
EvalCtxt::enter_canonical(
@@ -395,12 +405,10 @@ where
395405
/// `NormalizesTo` is only used by `AliasRelate`, all other callsites
396406
/// should use [`EvalCtxt::evaluate_goal`] which discards that empty
397407
/// storage.
398-
// FIXME(-Znext-solver=coinduction): `_source` is currently unused but will
399-
// be necessary once we implement the new coinduction approach.
400408
pub(super) fn evaluate_goal_raw(
401409
&mut self,
402410
goal_evaluation_kind: GoalEvaluationKind,
403-
_source: GoalSource,
411+
source: GoalSource,
404412
goal: Goal<I, I::Predicate>,
405413
) -> Result<(NestedNormalizationGoals<I>, HasChanged, Certainty), NoSolution> {
406414
let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
@@ -410,6 +418,7 @@ where
410418
self.cx(),
411419
self.search_graph,
412420
canonical_goal,
421+
self.step_kind_for_source(source),
413422
&mut goal_evaluation,
414423
);
415424
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>(

0 commit comments

Comments
 (0)