Skip to content

Commit c00b38e

Browse files
committed
Don't bother to save a block
1 parent 4316d0c commit c00b38e

16 files changed

+381
-269
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,10 +1226,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
12261226
if let Some(last_otherwise_block) = otherwise_block {
12271227
last_otherwise_block
12281228
} else {
1229-
// Any remaining candidates are unreachable.
1230-
if unmatched_candidates.is_empty() {
1231-
return;
1232-
}
12331229
self.cfg.start_new_block()
12341230
}
12351231
} else {

tests/mir-opt/building/issue_101867.main.built.after.mir

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ fn main() -> () {
2727
StorageLive(_5);
2828
PlaceMention(_1);
2929
_6 = discriminant(_1);
30-
switchInt(move _6) -> [1: bb5, otherwise: bb4];
30+
switchInt(move _6) -> [1: bb6, otherwise: bb4];
3131
}
3232

3333
bb1: {
3434
StorageLive(_3);
3535
StorageLive(_4);
36-
_4 = begin_panic::<&str>(const "explicit panic") -> bb8;
36+
_4 = begin_panic::<&str>(const "explicit panic") -> bb10;
3737
}
3838

3939
bb2: {
@@ -48,27 +48,35 @@ fn main() -> () {
4848
}
4949

5050
bb4: {
51-
goto -> bb7;
51+
goto -> bb9;
5252
}
5353

5454
bb5: {
55-
falseEdge -> [real: bb6, imaginary: bb4];
55+
goto -> bb3;
5656
}
5757

5858
bb6: {
59+
falseEdge -> [real: bb8, imaginary: bb4];
60+
}
61+
62+
bb7: {
63+
goto -> bb4;
64+
}
65+
66+
bb8: {
5967
_5 = ((_1 as Some).0: u8);
6068
_0 = const ();
6169
StorageDead(_5);
6270
StorageDead(_1);
6371
return;
6472
}
6573

66-
bb7: {
74+
bb9: {
6775
StorageDead(_5);
6876
goto -> bb1;
6977
}
7078

71-
bb8 (cleanup): {
79+
bb10 (cleanup): {
7280
resume;
7381
}
7482
}

tests/mir-opt/building/issue_49232.main.built.after.mir

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ fn main() -> () {
1717
}
1818

1919
bb1: {
20-
falseUnwind -> [real: bb2, unwind: bb12];
20+
falseUnwind -> [real: bb2, unwind: bb14];
2121
}
2222

2323
bb2: {
2424
StorageLive(_2);
2525
StorageLive(_3);
2626
_3 = const true;
2727
PlaceMention(_3);
28-
switchInt(_3) -> [0: bb4, otherwise: bb5];
28+
switchInt(_3) -> [0: bb4, otherwise: bb6];
2929
}
3030

3131
bb3: {
@@ -34,51 +34,59 @@ fn main() -> () {
3434
}
3535

3636
bb4: {
37-
falseEdge -> [real: bb6, imaginary: bb5];
37+
falseEdge -> [real: bb8, imaginary: bb6];
3838
}
3939

4040
bb5: {
41-
_0 = const ();
42-
goto -> bb11;
41+
goto -> bb3;
4342
}
4443

4544
bb6: {
46-
_2 = const 4_i32;
47-
goto -> bb9;
45+
_0 = const ();
46+
goto -> bb13;
4847
}
4948

5049
bb7: {
51-
unreachable;
50+
goto -> bb3;
5251
}
5352

5453
bb8: {
55-
goto -> bb9;
54+
_2 = const 4_i32;
55+
goto -> bb11;
5656
}
5757

5858
bb9: {
59+
unreachable;
60+
}
61+
62+
bb10: {
63+
goto -> bb11;
64+
}
65+
66+
bb11: {
5967
FakeRead(ForLet(None), _2);
6068
StorageDead(_3);
6169
StorageLive(_5);
6270
StorageLive(_6);
6371
_6 = &_2;
64-
_5 = std::mem::drop::<&i32>(move _6) -> [return: bb10, unwind: bb12];
72+
_5 = std::mem::drop::<&i32>(move _6) -> [return: bb12, unwind: bb14];
6573
}
6674

67-
bb10: {
75+
bb12: {
6876
StorageDead(_6);
6977
StorageDead(_5);
7078
_1 = const ();
7179
StorageDead(_2);
7280
goto -> bb1;
7381
}
7482

75-
bb11: {
83+
bb13: {
7684
StorageDead(_3);
7785
StorageDead(_2);
7886
return;
7987
}
8088

81-
bb12 (cleanup): {
89+
bb14 (cleanup): {
8290
resume;
8391
}
8492
}

0 commit comments

Comments
 (0)