1 // compile-flags: -Zunleash-the-miri-inside-of-you
3 #![feature(const_raw_ptr_deref)]
6 use std::cell::UnsafeCell;
8 // make sure we do not just intern this as mutable
9 const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
11 const MUTATING_BEHIND_RAW: () = {
12 // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
14 *MUTABLE_BEHIND_RAW = 99 //~ WARN skipping const checks
15 //~^ ERROR any use of this value will cause an error
16 //~^^ tried to modify constant memory