]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/uninhabited_enum_branching.rs
Rollup merge of #107719 - WaffleLapkin:de-arena-allocates-you-UwU, r=cjgillot
[rust.git] / tests / mir-opt / uninhabited_enum_branching.rs
1 enum Empty { }
2
3 // test matching an enum with uninhabited variants
4 enum Test1 {
5     A(Empty),
6     B(Empty),
7     C
8 }
9
10 // test an enum where the discriminants don't match the variant indexes
11 // (the optimization should do nothing here)
12 enum Test2 {
13     D = 4,
14     E = 5,
15 }
16
17 // EMIT_MIR uninhabited_enum_branching.main.UninhabitedEnumBranching.diff
18 // EMIT_MIR uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
19 fn main() {
20     match Test1::C {
21         Test1::A(_) => "A(Empty)",
22         Test1::B(_) => "B(Empty)",
23         Test1::C => "C",
24     };
25
26     match Test2::D {
27         Test2::D => "D",
28         Test2::E => "E",
29     };
30 }