summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/uninhabited_fallthrough_elimination.rs
blob: 7dd41aea5ed111d0e4dfd89118601041e7f25c2b (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
31
32
33
// skip-filecheck
enum Empty {}

enum S {
    A(Empty),
    B,
    C,
}

use S::*;

// EMIT_MIR uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff
fn keep_fallthrough(s: S) -> u32 {
    match s {
        A(_) => 1,
        B => 2,
        _ => 3,
    }
}

// EMIT_MIR uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff
fn eliminate_fallthrough(s: S) -> u32 {
    match s {
        C => 1,
        B => 2,
        _ => 3,
    }
}

fn main() {
    keep_fallthrough(B);
    eliminate_fallthrough(B);
}