summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/uninhabited_enum_branching.rs
blob: 0ef604c30883674426022bfe067f64feeef389da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
enum Empty { }

// test matching an enum with uninhabited variants
enum Test1 {
    A(Empty),
    B(Empty),
    C
}

// test an enum where the discriminants don't match the variant indexes
// (the optimization should do nothing here)
enum Test2 {
    D = 4,
    E = 5,
}

// EMIT_MIR uninhabited_enum_branching.main.UninhabitedEnumBranching.diff
// EMIT_MIR uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
fn main() {
    match Test1::C {
        Test1::A(_) => "A(Empty)",
        Test1::B(_) => "B(Empty)",
        Test1::C => "C",
    };

    match Test2::D {
        Test2::D => "D",
        Test2::E => "E",
    };
}