rust/tests/compile-fail/validation_illegal_write.rs
2018-06-05 18:08:18 +02:00

18 lines
394 B
Rust

// 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);
}