mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 11:53:44 +00:00
test more ways of mutably accessing a place
This commit is contained in:
parent
97974e3cab
commit
66b340f500
@ -13,8 +13,16 @@ fn main() {
|
||||
let mut u : U1<Vec<i32>> = U1 { x: () };
|
||||
unsafe { (*u.f).0 = Vec::new() }; // explicit deref, this compiles
|
||||
unsafe { u.f.0 = Vec::new() }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
unsafe { &mut (*u.f).0 }; // explicit deref, this compiles
|
||||
unsafe { &mut u.f.0 }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
unsafe { (*u.f).0.push(0) }; // explicit deref, this compiles
|
||||
unsafe { u.f.0.push(0) }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
|
||||
let mut u : U2<Vec<i32>> = U2 { x: () };
|
||||
unsafe { (*u.f.0).0 = Vec::new() }; // explicit deref, this compiles
|
||||
unsafe { u.f.0.0 = Vec::new() }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
unsafe { &mut (*u.f.0).0 }; // explicit deref, this compiles
|
||||
unsafe { &mut u.f.0.0 }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
unsafe { (*u.f.0).0.push(0) }; // explicit deref, this compiles
|
||||
unsafe { u.f.0.0.push(0) }; //~ERROR not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
}
|
||||
|
@ -7,14 +7,50 @@ LL | unsafe { u.f.0 = Vec::new() };
|
||||
= help: writing to this reference calls the destructor for the old value
|
||||
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor
|
||||
|
||||
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
--> $DIR/union-deref.rs:17:19
|
||||
|
|
||||
LL | unsafe { &mut u.f.0 };
|
||||
| ^^^
|
||||
|
|
||||
= help: writing to this reference calls the destructor for the old value
|
||||
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor
|
||||
|
||||
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
--> $DIR/union-deref.rs:19:14
|
||||
|
|
||||
LL | unsafe { u.f.0.push(0) };
|
||||
| ^^^
|
||||
|
|
||||
= help: writing to this reference calls the destructor for the old value
|
||||
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor
|
||||
|
||||
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
--> $DIR/union-deref.rs:23:14
|
||||
|
|
||||
LL | unsafe { u.f.0.0 = Vec::new() };
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: writing to this reference calls the destructor for the old value
|
||||
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
--> $DIR/union-deref.rs:25:19
|
||||
|
|
||||
LL | unsafe { &mut u.f.0.0 };
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: writing to this reference calls the destructor for the old value
|
||||
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor
|
||||
|
||||
error: not automatically applying `DerefMut` on `ManuallyDrop` union field
|
||||
--> $DIR/union-deref.rs:27:14
|
||||
|
|
||||
LL | unsafe { u.f.0.0.push(0) };
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: writing to this reference calls the destructor for the old value
|
||||
= help: add an explicit `*` if that is desired, or call `ptr::write` to not run the destructor
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user