diff options
Diffstat (limited to 'src/test/ui/moves/move-of-addr-of-mut.rs')
-rw-r--r-- | src/test/ui/moves/move-of-addr-of-mut.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/ui/moves/move-of-addr-of-mut.rs b/src/test/ui/moves/move-of-addr-of-mut.rs new file mode 100644 index 000000000..19fd70286 --- /dev/null +++ b/src/test/ui/moves/move-of-addr-of-mut.rs @@ -0,0 +1,12 @@ +// Ensure that taking a mutable raw ptr to an uninitialized variable does not change its +// initializedness. + +struct S; + +fn main() { + let mut x: S; + std::ptr::addr_of_mut!(x); //~ ERROR E0381 + + let y = x; // Should error here if `addr_of_mut` is ever allowed on uninitialized variables + drop(y); +} |