rust/tests/fail/stacked_borrows/illegal_write2.rs
2022-07-11 11:48:56 +00:00

9 lines
242 B
Rust

fn main() {
let target = &mut 42;
let target2 = target as *mut _;
drop(&mut *target); // reborrow
// Now make sure our ref is still the only one.
unsafe { *target2 = 13 }; //~ ERROR: borrow stack
let _val = *target;
}