]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-46845.rs
2 // To work around #46855
3 // compile-flags: -Z mir-opt-level=0
4 // Regression test for the inhabitedness of unions with uninhabited variants, issue #46845
11 // A single uninhabited variant shouldn't make the whole union uninhabited.
17 // If all the variants are uninhabited, however, the union should be uninhabited.
18 // NOTE(#49298) the union being uninhabited shouldn't change its size.
25 assert_eq
!(mem
::size_of
::<Foo
>(), 8);
26 // See the note on `Bar`'s definition for why this isn't `0`.
27 assert_eq
!(mem
::size_of
::<Bar
>(), 8);
29 let f
= [Foo { a: 42 }
, Foo { a: 10 }
];
30 println
!("{}", unsafe { f[0].a }
);
31 assert_eq
!(unsafe { f[1].a }
, 10);