2020-01-30 05:21:37 -06:00
|
|
|
// 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.
|
|
|
|
|
2022-06-21 01:40:39 -05:00
|
|
|
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;
|
2022-07-13 17:59:33 -05:00
|
|
|
let _fail = *y1; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
2022-06-21 01:40:39 -05:00
|
|
|
}
|
|
|
|
}
|