summary refs log tree commit diff
path: root/tests/ui/enum-discriminant/niche-prefer-zero.rs
blob: b1e2b1948f71f1903c367eb779c5ad897e09d383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Check that niche selection prefers zero.
// See https://github.com/rust-lang/rust/pull/87794
//@ run-pass
#[repr(u8)]
pub enum Size {
    One = 1,
    Two = 2,
    Three = 3,
}

fn main() {
    // check that `None` is zero
    assert_eq!(0, unsafe { std::mem::transmute::<Option<Size>, u8>(None) });
}