]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/miri_unleashed/mutable_const.rs
Add note to src/ci/docker/README.md about multiple docker images
[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 #![deny(const_err)]
5
6 use std::cell::UnsafeCell;
7
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 _;
10 //~^ WARN: skipping const checks
11
12 const MUTATING_BEHIND_RAW: () = {
13     // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
14     unsafe {
15         *MUTABLE_BEHIND_RAW = 99 //~ WARN skipping const checks
16         //~^ ERROR any use of this value will cause an error
17         //~^^ tried to modify constant memory
18     }
19 };
20
21 fn main() {}