1 // compile-flags: -Zunleash-the-miri-inside-of-you
5 use std::sync::atomic::AtomicUsize;
6 use std::sync::atomic::Ordering;
8 // These only fail during validation (they do not use but just create a reference to a static),
9 // so they cause an immediate error when *defining* the const.
11 const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value
12 //~| encountered a reference pointing to a static variable
13 static FOO: AtomicUsize = AtomicUsize::new(0);
14 unsafe { &*(&FOO as *const _ as *const usize) }
17 // ok some day perhaps
18 const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value
19 //~| encountered a reference pointing to a static variable
20 static FOO: usize = 0;