rust/tests/fail/stacked_borrows/illegal_write1.rs

10 lines
278 B
Rust
Raw Normal View History

2018-10-19 11:38:23 -05:00
fn main() {
let target = Box::new(42); // has an implicit raw
2018-11-15 12:49:00 -06:00
let xref = &*target;
{
let x: *mut u32 = xref as *const _ as *mut _;
2022-07-13 17:59:33 -05:00
unsafe { *x = 42 }; //~ ERROR: /write access .* tag only grants SharedReadOnly permission/
2018-11-15 12:49:00 -06:00
}
let _x = *xref;
2018-10-19 11:38:23 -05:00
}