]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/illegal_read8.rs
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / illegal_read8.rs
1 // Make sure that creating a raw ptr next to a shared ref works
2 // but the shared ref still gets invalidated when the raw ptr is used for writing.
3
4 fn main() {
5     unsafe {
6         use std::mem;
7         let x = &mut 0;
8         let y1: &i32 = mem::transmute(&*x); // launder lifetimes
9         let y2 = x as *mut _;
10         let _val = *y2;
11         let _val = *y1;
12         *y2 += 1;
13         let _fail = *y1; //~ ERROR: /read access .* tag does not exist in the borrow stack/
14     }
15 }