rust/tests/compile-fail/stacked_borrows/unescaped_local.rs
Ralf Jung ef52be031c adjust compile-fail error messages
This also passes miri-test-libstd!
2019-04-17 16:02:57 +02:00

9 lines
254 B
Rust

// Make sure we cannot use raw ptrs to access a local that
// we took the direct address of.
fn main() {
let mut x = 42;
let raw = &mut x as *mut i32 as usize as *mut i32;
let _ptr = &mut x;
unsafe { *raw = 13; } //~ ERROR borrow stack
}