Skip to content

Commit 1aaf609

Browse files
Auto merge of #142735 - lcnr:search_graph-5, r=<try>
lazily reevaluate nested goals It sure is a tragedy. Opening just so I have something to show for the last few weeks. This does not yet fix the perf regression in rayon. However, it does pass fuzzing and implements the simplest version of what I want this to be long term. r? ghost
2 parents f46ce66 + d372c6c commit 1aaf609

File tree

7 files changed

+760
-185
lines changed

7 files changed

+760
-185
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,15 @@ where
449449
let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
450450
let mut goal_evaluation =
451451
self.inspect.new_goal_evaluation(goal, &orig_values, goal_evaluation_kind);
452-
let canonical_result = self.search_graph.evaluate_goal(
453-
self.cx(),
454-
canonical_goal,
455-
self.step_kind_for_source(source),
456-
&mut goal_evaluation,
457-
);
452+
let canonical_result = self
453+
.search_graph
454+
.evaluate_goal(
455+
self.cx(),
456+
canonical_goal,
457+
self.step_kind_for_source(source),
458+
&mut goal_evaluation,
459+
)
460+
.1;
458461
goal_evaluation.query_result(canonical_result);
459462
self.inspect.goal_evaluation(goal_evaluation);
460463
let response = match canonical_result {

compiler/rustc_next_trait_solver/src/solve/search_graph.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ where
4848
) -> QueryResult<I> {
4949
match kind {
5050
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
51-
PathKind::Unknown => response_no_constraints(cx, input, Certainty::overflow(false)),
51+
PathKind::Unknown | PathKind::ForcedAmbiguity => {
52+
response_no_constraints(cx, input, Certainty::overflow(false))
53+
}
5254
// Even though we know these cycles to be unproductive, we still return
5355
// overflow during coherence. This is both as we are not 100% confident in
5456
// the implementation yet and any incorrect errors would be unsound there.

compiler/rustc_type_ir/src/search_graph/global_cache.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ impl<X: Cx> GlobalCache<X> {
4747
evaluation_result: EvaluationResult<X>,
4848
dep_node: X::DepNodeIndex,
4949
) {
50-
let EvaluationResult { encountered_overflow, required_depth, heads, nested_goals, result } =
51-
evaluation_result;
50+
let EvaluationResult {
51+
node_id: _,
52+
encountered_overflow,
53+
required_depth,
54+
heads,
55+
nested_goals,
56+
result,
57+
} = evaluation_result;
5258
debug_assert!(heads.is_empty());
5359
let result = cx.mk_tracked(result, dep_node);
5460
let entry = self.map.entry(input).or_default();

0 commit comments

Comments
 (0)