rust/tests/fail/stacked_borrows/illegal_read6.rs

11 lines
352 B
Rust
Raw Normal View History

// Creating a shared reference does not leak the data to raw pointers.
fn main() {
unsafe {
let x = &mut 0;
let raw = x as *mut _;
let x = &mut *x; // kill `raw`
let _y = &*x; // this should not activate `raw` again
2022-07-13 17:59:33 -05:00
let _val = *raw; //~ ERROR: /read access .* tag does not exist in the borrow stack/
}
}