fmt
This commit is contained in:
parent
e8739886f2
commit
2cb03ef739
1 changed files with 12 additions and 10 deletions
|
|
@ -265,13 +265,15 @@ fn write_does_not_invalidate_all_aliases() {
|
|||
assert_eq!(*x, 1337); // oops, the value changed! I guess not all pointers were invalidated
|
||||
}
|
||||
|
||||
fn box_into_raw_allows_interior_mutable_alias() { unsafe {
|
||||
let b = Box::new(std::cell::Cell::new(42));
|
||||
let raw = Box::into_raw(b);
|
||||
let c = &*raw;
|
||||
let d = raw.cast::<i32>(); // bypassing `Cell` -- only okay in Miri tests
|
||||
// `c` and `d` should permit arbitrary aliasing with each other now.
|
||||
*d = 1;
|
||||
c.set(2);
|
||||
drop(Box::from_raw(raw));
|
||||
} }
|
||||
fn box_into_raw_allows_interior_mutable_alias() {
|
||||
unsafe {
|
||||
let b = Box::new(std::cell::Cell::new(42));
|
||||
let raw = Box::into_raw(b);
|
||||
let c = &*raw;
|
||||
let d = raw.cast::<i32>(); // bypassing `Cell` -- only okay in Miri tests
|
||||
// `c` and `d` should permit arbitrary aliasing with each other now.
|
||||
*d = 1;
|
||||
c.set(2);
|
||||
drop(Box::from_raw(raw));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue