Skip to content

Commit d01b003

Browse files
committed
w
1 parent 66e1871 commit d01b003

File tree

1 file changed

+35
-37
lines changed
  • compiler/rustc_type_ir/src/search_graph

1 file changed

+35
-37
lines changed

compiler/rustc_type_ir/src/search_graph/mod.rs

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,10 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
12241224
&new_stack_entry,
12251225
|_, result| result,
12261226
);
1227-
self.tree.set_rebase_kind(new_stack_entry.node_id, tree::RebaseEntriesKind::Normal);
1227+
self.tree.set_rebase_kind(
1228+
new_stack_entry.node_id,
1229+
tree::RebaseEntriesKind::Normal,
1230+
);
12281231
return EvaluationResult::finalize(
12291232
new_stack_entry,
12301233
encountered_overflow,
@@ -1300,6 +1303,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13001303
)
13011304
}
13021305
Some(tree::RebaseEntriesKind::Ambiguity) => {
1306+
debug!(?reeval_entry.input, "rebase entries while truncating stack");
13031307
Self::rebase_provisional_cache_entries(
13041308
stack,
13051309
provisional_cache,
@@ -1308,18 +1312,46 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13081312
)
13091313
}
13101314
Some(tree::RebaseEntriesKind::Overflow) => {
1315+
debug!(?reeval_entry.input, "rebase entries while truncating stack");
13111316
Self::rebase_provisional_cache_entries(
13121317
stack,
13131318
provisional_cache,
13141319
&reeval_entry,
13151320
|input, _| D::on_fixpoint_overflow(cx, input),
13161321
)
13171322
}
1318-
None | _ => {
1319-
Self::clear_dependent_provisional_results(stack, provisional_cache)
1323+
None => Self::clear_dependent_provisional_results(stack, provisional_cache),
1324+
}
1325+
1326+
let entry = provisional_cache.entry(reeval_entry.input).or_default();
1327+
for (head, path_to_nested) in heads.iter() {
1328+
let path_from_head =
1329+
Self::cycle_path_kind(&stack, reeval_entry.step_kind_from_parent, head);
1330+
for path_kind in path_to_nested.extend_with(path_from_head).iter_paths() {
1331+
let usage_kind = UsageKind::Single(path_kind);
1332+
stack[head].has_been_used = Some(
1333+
stack[head]
1334+
.has_been_used
1335+
.map_or(usage_kind, |prev| prev.merge(usage_kind)),
1336+
);
13201337
}
13211338
}
1339+
let path_from_head = Self::cycle_path_kind(
1340+
&stack,
1341+
reeval_entry.step_kind_from_parent,
1342+
heads.highest_cycle_head(),
1343+
);
1344+
let provisional_cache_entry = ProvisionalCacheEntry {
1345+
entry_node_id: reeval_entry.node_id,
1346+
encountered_overflow,
1347+
heads: heads.clone(),
1348+
path_from_head,
1349+
result,
1350+
};
1351+
debug!(?reeval_entry.input, ?provisional_cache_entry);
1352+
entry.push(provisional_cache_entry);
13221353
} else {
1354+
debug!(?reeval_entry.input, "rebase entries while truncating stack");
13231355
Self::clear_dependent_provisional_results(stack, provisional_cache);
13241356
}
13251357

@@ -1331,34 +1363,6 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13311363
reeval_entry.encountered_overflow,
13321364
UpdateParentGoalCtxt::Ordinary(&reeval_entry.nested_goals),
13331365
);
1334-
let entry = provisional_cache.entry(reeval_entry.input).or_default();
1335-
1336-
for (head, path_to_nested) in heads.iter() {
1337-
let path_from_head =
1338-
Self::cycle_path_kind(&stack, reeval_entry.step_kind_from_parent, head);
1339-
for path_kind in path_to_nested.extend_with(path_from_head).iter_paths() {
1340-
let usage_kind = UsageKind::Single(path_kind);
1341-
stack[head].has_been_used = Some(
1342-
stack[head]
1343-
.has_been_used
1344-
.map_or(usage_kind, |prev| prev.merge(usage_kind)),
1345-
);
1346-
}
1347-
}
1348-
let path_from_head = Self::cycle_path_kind(
1349-
&stack,
1350-
reeval_entry.step_kind_from_parent,
1351-
heads.highest_cycle_head(),
1352-
);
1353-
let provisional_cache_entry = ProvisionalCacheEntry {
1354-
entry_node_id: reeval_entry.node_id,
1355-
encountered_overflow,
1356-
heads: heads.clone(),
1357-
path_from_head,
1358-
result,
1359-
};
1360-
debug!(?provisional_cache_entry);
1361-
entry.push(provisional_cache_entry);
13621366
}
13631367
};
13641368

@@ -1385,12 +1389,6 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
13851389
if entry_node_id < node_id {
13861390
continue;
13871391
}
1388-
// This provisional cache entry was computed with the current goal on the
1389-
// stack. Check whether it depends on it.
1390-
if !self.tree.get_heads(entry_node_id).contains_stack_entry(current_depth) {
1391-
continue;
1392-
}
1393-
13941392
// We've evaluated the `entry_node_id` before evaluating this goal. In case
13951393
// that node and its parents has not changed, we can reinsert the cache entry
13961394
// before starting to reevaluate it.

0 commit comments

Comments
 (0)