rust/tests/compile-fail/validation_illegal_write.rs

18 lines
394 B
Rust
Raw Normal View History

2018-05-09 08:54:45 -05:00
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {
pub(crate) fn safe(x: &u32) {
let x : &mut u32 = unsafe { &mut *(x as *const _ as *mut _) };
*x = 42; //~ ERROR: in conflict with lock ReadLock
}
}
fn main() {
let target = &mut 42;
let target_ref = ⌖
// do a reborrow, but we keep the lock
safe::safe(&*target);
}