summaryrefslogtreecommitdiffstats
path: root/tests/ui/enum-discriminant/issue-51582.rs
blob: 40a70c623a741bf6f6f55767dab8f5843565ce3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// run-pass
#![feature(core_intrinsics)]

#[repr(i8)]
pub enum Enum {
    VariantA,
    VariantB,
}

fn make_b() -> Enum { Enum::VariantB }

fn main() {
    assert_eq!(1, make_b() as i8);
    assert_eq!(1, make_b() as u8);
    assert_eq!(1, make_b() as i32);
    assert_eq!(1, make_b() as u32);
    assert_eq!(1, std::intrinsics::discriminant_value(&make_b()));
}