rust/tests/fail/stacked_borrows/illegal_write3.rs

11 lines
348 B
Rust
Raw Normal View History

2018-10-19 18:38:23 +02:00
fn main() {
let target = 42;
// Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref.
let r#ref = ⌖ // freeze
let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag
unsafe {
2022-06-21 11:40:02 -07:00
*ptr = 42; //~ ERROR only grants SharedReadOnly permission
}
let _val = *r#ref;
2018-10-19 18:38:23 +02:00
}