diff options
Diffstat (limited to 'tests/ui/borrowck/borrowck-union-uninitialized.rs')
-rw-r--r-- | tests/ui/borrowck/borrowck-union-uninitialized.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-union-uninitialized.rs b/tests/ui/borrowck/borrowck-union-uninitialized.rs new file mode 100644 index 000000000..bbe9f22aa --- /dev/null +++ b/tests/ui/borrowck/borrowck-union-uninitialized.rs @@ -0,0 +1,18 @@ +struct S { + a: u8, +} + +union U { + a: u8, +} + +fn main() { + unsafe { + let mut s: S; + let mut u: U; + s.a = 0; //~ ERROR E0381 + u.a = 0; //~ ERROR E0381 + let sa = s.a; + let ua = u.a; + } +} |