]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/miri_unleashed/mutable_references.rs
1 // compile-flags: -Zunleash-the-miri-inside-of-you
2 #![feature(const_mut_refs)]
5 use std
::cell
::UnsafeCell
;
7 // a test demonstrating what things we could allow with a smarter const qualification
9 // this is fine because is not possible to mutate through an immutable reference.
10 static FOO
: &&mut u32 = &&mut 42;
12 // this is fine because accessing an immutable static `BAR` is equivalent to accessing `*&BAR`
13 // which puts the mutable reference behind an immutable one.
14 static BAR
: &mut () = &mut ();
18 // this is fine for the same reason as `BAR`.
19 static BOO
: &mut Foo
<()> = &mut Foo(());
22 x
: &'
static UnsafeCell
<i32>,
25 unsafe impl Sync
for Meh {}
27 static MEH
: Meh
= Meh
{
28 x
: &UnsafeCell
::new(42),
29 //~^ WARN: skipping const checks
32 // this is fine for the same reason as `BAR`.
33 static OH_YES
: &mut i32 = &mut 42;
39 *OH_YES
= 99; //~ ERROR cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item