about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/stacked_borrows/illegal_read8.rs
blob: f0a1658a5a23a4b9659eaad4a0d621b85d739b4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Make sure that creating a raw ptr next to a shared ref works
// but the shared ref still gets invalidated when the raw ptr is used for writing.

fn main() {
    unsafe {
        use std::mem;
        let x = &mut 0;
        let y1: &i32 = mem::transmute(&*x); // launder lifetimes
        let y2 = x as *mut _;
        let _val = *y2;
        let _val = *y1;
        *y2 += 1;
        let _fail = *y1; //~ ERROR: /read access .* tag does not exist in the borrow stack/
    }
}