Skip to content

lazily reevaluate nested goals #142735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,15 @@ where
let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
let mut goal_evaluation =
self.inspect.new_goal_evaluation(goal, &orig_values, goal_evaluation_kind);
let canonical_result = self.search_graph.evaluate_goal(
self.cx(),
canonical_goal,
self.step_kind_for_source(source),
&mut goal_evaluation,
);
let canonical_result = self
.search_graph
.evaluate_goal(
self.cx(),
canonical_goal,
self.step_kind_for_source(source),
&mut goal_evaluation,
)
.1;
goal_evaluation.query_result(canonical_result);
self.inspect.goal_evaluation(goal_evaluation);
let response = match canonical_result {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/search_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ where
) -> QueryResult<I> {
match kind {
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
PathKind::Unknown => response_no_constraints(cx, input, Certainty::overflow(false)),
PathKind::Unknown | PathKind::ForcedAmbiguity => {
response_no_constraints(cx, input, Certainty::overflow(false))
}
// Even though we know these cycles to be unproductive, we still return
// overflow during coherence. This is both as we are not 100% confident in
// the implementation yet and any incorrect errors would be unsound there.
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_type_ir/src/search_graph/global_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ impl<X: Cx> GlobalCache<X> {
evaluation_result: EvaluationResult<X>,
dep_node: X::DepNodeIndex,
) {
let EvaluationResult { encountered_overflow, required_depth, heads, nested_goals, result } =
evaluation_result;
let EvaluationResult {
node_id: _,
encountered_overflow,
required_depth,
heads,
nested_goals,
result,
} = evaluation_result;
debug_assert!(heads.is_empty());
let result = cx.mk_tracked(result, dep_node);
let entry = self.map.entry(input).or_default();
Expand Down
Loading
Loading