Skip to content

Commit 834f043

Browse files
committed
Fix expansion of or-patterns
1 parent 5df6f72 commit 834f043

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14111411
break;
14121412
}
14131413
}
1414+
if expand_until != 0 {
1415+
expand_until = i + 1;
1416+
}
14141417
}
14151418
let (candidates_to_expand, remaining_candidates) = candidates.split_at_mut(expand_until);
14161419

tests/mir-opt/building/match/simple_match.match_enum.built.after.mir

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ fn match_enum(_1: E1) -> bool {
44
debug x => _1;
55
let mut _0: bool;
66
let mut _2: isize;
7-
let mut _3: isize;
87

98
bb0: {
109
PlaceMention(_1);
1110
_2 = discriminant(_1);
12-
switchInt(move _2) -> [0: bb3, 1: bb5, otherwise: bb2];
11+
switchInt(move _2) -> [0: bb3, 1: bb5, 2: bb7, otherwise: bb2];
1312
}
1413

1514
bb1: {
@@ -18,37 +17,36 @@ fn match_enum(_1: E1) -> bool {
1817
}
1918

2019
bb2: {
21-
_3 = discriminant(_1);
22-
switchInt(move _3) -> [2: bb8, otherwise: bb1];
20+
goto -> bb1;
2321
}
2422

2523
bb3: {
26-
goto -> bb7;
24+
goto -> bb9;
2725
}
2826

2927
bb4: {
3028
goto -> bb2;
3129
}
3230

3331
bb5: {
34-
goto -> bb7;
32+
goto -> bb9;
3533
}
3634

3735
bb6: {
3836
goto -> bb2;
3937
}
4038

4139
bb7: {
42-
falseEdge -> [real: bb10, imaginary: bb2];
40+
_0 = const false;
41+
goto -> bb11;
4342
}
4443

4544
bb8: {
46-
_0 = const false;
47-
goto -> bb11;
45+
goto -> bb2;
4846
}
4947

5048
bb9: {
51-
goto -> bb1;
49+
falseEdge -> [real: bb10, imaginary: bb7];
5250
}
5351

5452
bb10: {

0 commit comments

Comments
 (0)