]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/miri_unleashed/mutable_references.rs
Rollup merge of #64603 - gilescope:unused-lifetime-warning, r=matthewjasper
[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 //~^ WARN: skipping const checks
10
11 static BAR: &mut () = &mut ();
12 //~^ WARN: skipping const checks
13
14 struct Foo<T>(T);
15
16 static BOO: &mut Foo<()> = &mut Foo(());
17 //~^ WARN: skipping const checks
18
19 struct Meh {
20     x: &'static UnsafeCell<i32>,
21 }
22
23 unsafe impl Sync for Meh {}
24
25 static MEH: Meh = Meh {
26     x: &UnsafeCell::new(42),
27     //~^ WARN: skipping const checks
28 };
29
30 static OH_YES: &mut i32 = &mut 42;
31 //~^ WARN: skipping const checks
32
33 fn main() {
34     unsafe {
35         *MEH.x.get() = 99;
36     }
37     *OH_YES = 99; //~ ERROR cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
38 }