]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/miri_unleashed/mutable_references.rs
Auto merge of #61172 - matthewjasper:cleanup-implied-bounds-lint, r=varkor
[rust.git] / src / test / ui / consts / miri_unleashed / mutable_references.rs
1 // compile-flags: -Zunleash-the-miri-inside-of-you
2 #![allow(const_err)]
3
4 use std::cell::UnsafeCell;
5
6 // a test demonstrating what things we could allow with a smarter const qualification
7
8 static FOO: &&mut u32 = &&mut 42;
9
10 static BAR: &mut () = &mut ();
11
12 struct Foo<T>(T);
13
14 static BOO: &mut Foo<()> = &mut Foo(());
15
16 struct Meh {
17     x: &'static UnsafeCell<i32>,
18 }
19
20 unsafe impl Sync for Meh {}
21
22 static MEH: Meh = Meh {
23     x: &UnsafeCell::new(42),
24 };
25
26 static OH_YES: &mut i32 = &mut 42;
27
28 fn main() {
29     unsafe {
30         *MEH.x.get() = 99; //~ WARN skipping const checks
31         //~^ WARN skipping const checks
32     }
33     *OH_YES = 99; //~ ERROR cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
34     //~^ WARN skipping const checks
35 }