rust/tests/compile-fail-fullmir/stacked_borrows/illegal_write3.rs
2018-11-16 10:01:54 +01:00

9 lines
312 B
Rust

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 { *ptr = 42; }
let _val = *r#ref; //~ ERROR is not frozen
}