Skip to content

Commit 5df6f72

Browse files
committed
Add test
1 parent 536235f commit 5df6f72

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// MIR for `match_enum` after built
2+
3+
fn match_enum(_1: E1) -> bool {
4+
debug x => _1;
5+
let mut _0: bool;
6+
let mut _2: isize;
7+
let mut _3: isize;
8+
9+
bb0: {
10+
PlaceMention(_1);
11+
_2 = discriminant(_1);
12+
switchInt(move _2) -> [0: bb3, 1: bb5, otherwise: bb2];
13+
}
14+
15+
bb1: {
16+
FakeRead(ForMatchedPlace(None), _1);
17+
unreachable;
18+
}
19+
20+
bb2: {
21+
_3 = discriminant(_1);
22+
switchInt(move _3) -> [2: bb8, otherwise: bb1];
23+
}
24+
25+
bb3: {
26+
goto -> bb7;
27+
}
28+
29+
bb4: {
30+
goto -> bb2;
31+
}
32+
33+
bb5: {
34+
goto -> bb7;
35+
}
36+
37+
bb6: {
38+
goto -> bb2;
39+
}
40+
41+
bb7: {
42+
falseEdge -> [real: bb10, imaginary: bb2];
43+
}
44+
45+
bb8: {
46+
_0 = const false;
47+
goto -> bb11;
48+
}
49+
50+
bb9: {
51+
goto -> bb1;
52+
}
53+
54+
bb10: {
55+
_0 = const true;
56+
goto -> bb11;
57+
}
58+
59+
bb11: {
60+
return;
61+
}
62+
}

tests/mir-opt/building/match/simple_match.rs

+14
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,18 @@ fn match_bool(x: bool) -> usize {
99
}
1010
}
1111

12+
pub enum E1 {
13+
V1,
14+
V2,
15+
V3,
16+
}
17+
18+
// EMIT_MIR simple_match.match_enum.built.after.mir
19+
pub fn match_enum(x: E1) -> bool {
20+
match x {
21+
E1::V1 | E1::V2 => true,
22+
E1::V3 => false,
23+
}
24+
}
25+
1226
fn main() {}

0 commit comments

Comments
 (0)