diff options
| author | Ralf Jung <post@ralfj.de> | 2025-07-16 15:11:11 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-07-16 15:29:52 +0200 |
| commit | 8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0 (patch) | |
| tree | 96f27edd5f2e963cce5fea17cfacad2a342aa98c /tests/ui | |
| parent | fd48b7b8dd911229b635f7969e6213b5af337b7d (diff) | |
| download | rust-8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0.tar.gz rust-8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0.zip | |
const heap: fix ICE on forgotten make_global
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.rs | 9 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.stderr | 8 |
2 files changed, 5 insertions, 12 deletions
diff --git a/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.rs b/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.rs index 201fa715022..e44a3f7a23c 100644 --- a/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.rs +++ b/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.rs @@ -1,12 +1,11 @@ -// We unleash Miri here since this test demonstrates code that bypasses the checks against interning -// mutable pointers, which currently ICEs. Unleashing Miri silences the ICE. -//@ compile-flags: -Zunleash-the-miri-inside-of-you +// Ensure that we reject interning `const_allocate`d allocations in the final value of constants +// if they have not been made global through `const_make_global`. This covers the case where the +// pointer is even still mutable, which used to ICE. #![feature(core_intrinsics)] #![feature(const_heap)] use std::intrinsics; const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; -//~^ error: mutable pointer in final value of constant -//~| error: encountered `const_allocate` pointer in final value that was not made global +//~^ error: encountered `const_allocate` pointer in final value that was not made global fn main() {} diff --git a/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.stderr b/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.stderr index eae79d24797..2445ce633d6 100644 --- a/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.stderr +++ b/tests/ui/consts/const-eval/heap/ptr_not_made_global_mut.stderr @@ -6,11 +6,5 @@ LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 | = note: use `const_make_global` to make allocated pointers immutable before returning -error: encountered mutable pointer in final value of constant - --> $DIR/ptr_not_made_global_mut.rs:8:1 - | -LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error |
