1 // compile-flags: -Zunleash-the-miri-inside-of-you
4 use std::cell::UnsafeCell;
6 // a test demonstrating what things we could allow with a smarter const qualification
8 // this is fine because is not possible to mutate through an immutable reference.
9 static FOO: &&mut u32 = &&mut 42;
11 // this is fine because accessing an immutable static `BAR` is equivalent to accessing `*&BAR`
12 // which puts the mutable reference behind an immutable one.
13 static BAR: &mut () = &mut ();
17 // this is fine for the same reason as `BAR`.
18 static BOO: &mut Foo<()> = &mut Foo(());
20 // interior mutability is fine
22 x: &'static UnsafeCell<i32>,
24 unsafe impl Sync for Meh {}
25 static MEH: Meh = Meh {
26 x: &UnsafeCell::new(42),
29 // this is fine for the same reason as `BAR`.
30 static OH_YES: &mut i32 = &mut 42;
36 *OH_YES = 99; //~ ERROR cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item