mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 21:47:15 +03:00
test that creating a 2nd mutable ref from a NonNull invalidates the first
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
use std::ptr::NonNull;
|
||||
|
||||
fn main() { unsafe {
|
||||
let x = &mut 0;
|
||||
let mut ptr1 = NonNull::from(x);
|
||||
let mut ptr2 = ptr1.clone();
|
||||
let raw1 = ptr1.as_mut();
|
||||
let _raw2 = ptr2.as_mut();
|
||||
let _val = *raw1; //~ ERROR borrow stack
|
||||
} }
|
||||
Reference in New Issue
Block a user