]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/miri_unleashed/mutable_references_ice.rs
Rollup merge of #64603 - gilescope:unused-lifetime-warning, r=matthewjasper
[rust.git] / src / test / ui / consts / miri_unleashed / mutable_references_ice.rs
1 // compile-flags: -Zunleash-the-miri-inside-of-you
2 // failure-status: 101
3 // rustc-env:RUST_BACKTRACE=0
4 // normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
5 // normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
6 // normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC"
7
8 #![allow(const_err)]
9
10 use std::cell::UnsafeCell;
11
12 // this test ICEs to ensure that our mutability story is sound
13
14 struct Meh {
15     x: &'static UnsafeCell<i32>,
16 }
17
18 unsafe impl Sync for Meh {}
19
20 // the following will never be ok!
21 const MUH: Meh = Meh {
22     x: &UnsafeCell::new(42), //~ WARN: skipping const checks
23 };
24
25 fn main() {
26     unsafe {
27         *MUH.x.get() = 99;
28     }
29 }