Skip to content

Commit c7a9f61

Browse files
authored
print: try harder to ensure DbgScope parents come before their children. (#19)
Follow-up to: - #18 Overlooked an edge case (`scope.parent()` being in the `claimed` map, but at a later position than `scope` itself, i.e. part of the same "claim" batch) in the original PR, now the order is properly "outside-in": |Before|After| |-|-| |![image](https://github.com/user-attachments/assets/e80ddfc8-62d7-4e6a-8b98-5c791bbed66b)|![image](https://github.com/user-attachments/assets/45476c72-1790-482e-a1fd-b3ea7443f4ac)|
2 parents 1db5c95 + ef2fc59 commit c7a9f61

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/print/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,14 @@ impl<'a> Printer<'a> {
13821382
// HACK(eddyb) also claim all yet-unclaimed parent scopes.
13831383
let stack = &mut reusable_dbg_scope_stack;
13841384
stack.clear();
1385-
stack.extend(
1386-
scope.parents(cx).take_while(|parent| !claimed.contains(parent)),
1387-
);
1385+
stack.extend(scope.parents(cx).take_while(|parent| {
1386+
claimed.get_index_of(parent).is_none_or(|parent_claim_idx| {
1387+
// HACK(eddyb) scopes later in `newly_claimed_range`
1388+
// get treated as unclaimed, in order to claim them
1389+
// even earlier (just before they're first needed).
1390+
parent_claim_idx > claim_idx
1391+
})
1392+
}));
13881393
for parent in stack.drain(..).rev() {
13891394
placements.insert(parent);
13901395
}

0 commit comments

Comments
 (0)