Skip to content

Commit bcc6c3b

Browse files
committed
impoopment
1 parent fe2752f commit bcc6c3b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

compiler/rustc_type_ir/src/search_graph/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13001300

13011301
let cycles = self.tree.rerun_get_and_reset_cycles(prev_stack_entry.node_id);
13021302
let current_stack_len = self.stack.len();
1303-
let mut has_changed = HashSet::default();
1303+
let mut was_reevaluated = HashSet::default();
13041304
'outer: for cycle in cycles {
13051305
let &tree::Cycle { node_id: cycle_node_id, ref provisional_results } =
13061306
self.tree.get_cycle(cycle);
@@ -1329,7 +1329,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13291329
// We've evaluated the `entry_node_id` before evaluating this goal. In case
13301330
// that node and its parents has not changed, we can reinsert the cache entry
13311331
// before starting to reevaluate it.
1332-
if !self.tree.goal_or_parent_has_changed(node_id, &has_changed, entry_node_id) {
1332+
if !self.tree.goal_or_parent_was_reevaluated(node_id, &was_reevaluated, entry_node_id) {
13331333
continue;
13341334
}
13351335
}
@@ -1369,7 +1369,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13691369
}
13701370
}
13711371
(Some(&(node_id, info)), None) => {
1372-
if current_goal.0 == node_id {
1372+
if was_reevaluated.contains(&node_id) {
13731373
debug!(parent = ?info.input, cycle = ?added_goals.last().unwrap(), "reevaluated parent, skip cycle");
13741374
continue 'outer;
13751375
} else {
@@ -1427,15 +1427,12 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
14271427
current_goal.1.step_kind_from_parent,
14281428
inspect,
14291429
);
1430+
was_reevaluated.insert(current_goal.0);
14301431
if node_id.is_some_and(|node_id| self.tree.result_matches(current_goal.0, node_id))
14311432
{
1432-
// TODO: This seems wrong. If a later loop reevaluates this goal again, we'd use
1433-
// its updated `NodeId`.
1434-
removed_entries.remove(&current_goal.0);
14351433
debug!(input = ?current_goal.1.input, ?result, "goal did not change");
14361434
continue 'outer;
14371435
} else {
1438-
has_changed.insert(current_goal.0);
14391436
debug!(input = ?current_goal.1.input, ?result, "goal did change");
14401437
if self.stack.len() > current_stack_len {
14411438
let parent = self.stack.pop();
@@ -1481,7 +1478,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
14811478
);
14821479

14831480
for (entry_node_id, (input, entry)) in removed_entries {
1484-
if !self.tree.goal_or_parent_has_changed(node_id, &has_changed, entry_node_id) {
1481+
if !self.tree.goal_or_parent_was_reevaluated(node_id, &was_reevaluated, entry_node_id) {
14851482
self.provisional_cache.entry(input).or_default().push(entry);
14861483
}
14871484
}

compiler/rustc_type_ir/src/search_graph/tree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ impl<X: Cx> SearchTree<X> {
175175
}
176176
}
177177

178-
pub(super) fn goal_or_parent_has_changed(
178+
pub(super) fn goal_or_parent_was_reevaluated(
179179
&self,
180180
cycle_head: NodeId,
181-
has_changed: &HashSet<NodeId>,
181+
was_reevaluated: &HashSet<NodeId>,
182182
mut node_id: NodeId,
183183
) -> bool {
184184
loop {
185185
if node_id == cycle_head {
186186
return false;
187-
} else if has_changed.contains(&node_id) {
187+
} else if was_reevaluated.contains(&node_id) {
188188
return true;
189189
} else {
190190
node_id = self.nodes[node_id].parent.unwrap();

0 commit comments

Comments
 (0)