Uninhabited variants should ideally be irrelevant to the representation, just like in enums.
As a test, this prints out 0 instead of 8:
#![feature(never_type)]
use std::mem;
union Foo {
a: u64,
b: !
}
fn main() {
println!("{}", mem::size_of::<Foo>());
}
This happens because rustc considers unions more like structs than enums, and the test for uninhabitedness sees a single variant with two fields, one of which is uninhabited.
I have a fix for this, but it's slightly easier to bundle it with some other changes I'm working on.
Uninhabited variants should ideally be irrelevant to the representation, just like in enums.
As a test, this prints out 0 instead of 8:
This happens because rustc considers unions more like structs than enums, and the test for uninhabitedness sees a single variant with two fields, one of which is uninhabited.
I have a fix for this, but it's slightly easier to bundle it with some other changes I'm working on.