]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/miri_unleashed/mutable_const.rs
5866f8b4f246f5543d5c7538d23f0ddd0e34645e
[rust.git] / src / test / ui / consts / miri_unleashed / mutable_const.rs
1 // compile-flags: -Zunleash-the-miri-inside-of-you
2
3 #![feature(const_raw_ptr_deref)]
4 #![feature(const_mut_refs)]
5 #![deny(const_err)] // FIXME: ICEs with allow! See #71316.
6
7 use std::cell::UnsafeCell;
8
9 // make sure we do not just intern this as mutable
10 const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
11 //~^ WARN: skipping const checks
12
13 const MUTATING_BEHIND_RAW: () = {
14     // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
15     unsafe {
16         *MUTABLE_BEHIND_RAW = 99 //~ ERROR any use of this value will cause an error
17     }
18 };
19
20 fn main() {}