Skip to content

Commit f2a751e

Browse files
committed
test(integration): cover static and vtable fallback behavior
1 parent 4209eb5 commit f2a751e

4 files changed

Lines changed: 3542 additions & 6 deletions

File tree

src/printer/mir_visitor.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ fn collect_alloc(
266266
}
267267
}
268268
GlobalAlloc::Static(_) => {
269-
// Keep established behavior for direct pointer/reference types.
270-
// Recovery is only for non-builtin-deref container paths.
269+
// Keep builtin-deref behavior; recover only non-builtin-deref cases.
271270
if kind.clone().builtin_deref(true).is_none() {
272271
let prov_ty = get_prov_ty(ty, &offset);
273272
debug_log_println!(
@@ -283,7 +282,7 @@ fn collect_alloc(
283282
.visited_allocs
284283
.insert(val, (p_ty, global_alloc.clone()));
285284
} else {
286-
// Unknown is safer than recording an incorrect outer container type.
285+
// Recovery failed: do not treat outer container `ty` as pointee.
287286
val_collector
288287
.visited_allocs
289288
.insert(val, (opaque_placeholder_ty(), global_alloc.clone()));
@@ -295,8 +294,7 @@ fn collect_alloc(
295294
}
296295
}
297296
GlobalAlloc::VTable(_, _) => {
298-
// Same policy as static allocs: preserve direct-deref behavior,
299-
// recover only on the fallback path.
297+
// Same policy as Static: keep builtin-deref, recover non-builtin-deref.
300298
if kind.clone().builtin_deref(true).is_none() {
301299
let prov_ty = get_prov_ty(ty, &offset);
302300
debug_log_println!(
@@ -312,7 +310,7 @@ fn collect_alloc(
312310
.visited_allocs
313311
.insert(val, (p_ty, global_alloc.clone()));
314312
} else {
315-
// Unknown is safer than recording an incorrect outer container type.
313+
// Unknown is safer than wrong pointee type.
316314
val_collector
317315
.visited_allocs
318316
.insert(val, (opaque_placeholder_ty(), global_alloc.clone()));

tests/integration/normalise-filter.jq

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@
2929
( .types | map(select(.[0].FunType) | sort) )
3030
] | flatten(1) )
3131
}
32+
# drop unstable compiler-internal ids that are unrelated to this regression
33+
| walk(if type == "object" then del(.def_id) else . end)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::fmt::Debug;
2+
3+
static S: u8 = 7;
4+
const OBJS: [&'static dyn Debug; 1] = [&S as &dyn Debug];
5+
6+
fn main() {
7+
// Keep trait-object constant usage so both Static and VTable allocs are emitted.
8+
std::hint::black_box(OBJS[0]);
9+
}

0 commit comments

Comments
 (0)