]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/uninhabited_fallthrough_elimination.rs
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
[rust.git] / tests / mir-opt / uninhabited_fallthrough_elimination.rs
1 enum Empty {}
2
3 enum S {
4     A(Empty),
5     B,
6     C,
7 }
8
9 use S::*;
10
11 // EMIT_MIR uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff
12 fn keep_fallthrough(s: S) -> u32 {
13     match s {
14         A(_) => 1,
15         B => 2,
16         _ => 3,
17     }
18 }
19
20 // EMIT_MIR uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff
21 fn eliminate_fallthrough(s: S) -> u32 {
22     match s {
23         C => 1,
24         B => 2,
25         _ => 3,
26     }
27 }
28
29 fn main() {
30     keep_fallthrough(B);
31     eliminate_fallthrough(B);
32 }