test that creating a 2nd mutable ref from a NonNull invalidates the first
This commit is contained in:
parent
ae9e9cb47c
commit
7d9dc6e698
1 changed files with 10 additions and 0 deletions
|
|
@ -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
|
||||
} }
|
||||
Loading…
Add table
Add a link
Reference in a new issue