rust/tests/fail/stacked_borrows/illegal_write2.rs

11 lines
253 B
Rust
Raw Normal View History

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 {
2022-06-21 13:40:02 -05:00
*target2 = 13; //~ ERROR borrow stack
}
let _val = *target;
}