Don't try to save an extra block · rust-lang/rust@8a222ff (original) (raw)

File tree

15 files changed

lines changed

15 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -2021,19 +2021,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2021 2021
2022 2022 // The block that we should branch to if none of the
2023 2023 // `target_candidates` match.
2024 -let remainder_start = if !remaining_candidates.is_empty() {
2025 -let remainder_start = self.cfg.start_new_block();
2026 -self.match_candidates(
2027 - span,
2028 - scrutinee_span,
2029 - remainder_start,
2030 - otherwise_block,
2031 - remaining_candidates,
2032 -);
2033 - remainder_start
2034 -} else {
2035 - otherwise_block
2036 -};
2024 +let remainder_start = self.cfg.start_new_block();
2037 2025
2038 2026 // For each outcome of test, process the candidates that still apply.
2039 2027 let target_blocks: FxIndexMap<_, _> = target_candidates
@@ -2061,6 +2049,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2061 2049 &test,
2062 2050 target_blocks,
2063 2051 );
2052 +
2053 +self.match_candidates(
2054 + span,
2055 + scrutinee_span,
2056 + remainder_start,
2057 + otherwise_block,
2058 + remaining_candidates,
2059 +);
2064 2060 }
2065 2061 }
2066 2062
Original file line number Diff line number Diff line change
@@ -27,13 +27,13 @@ fn main() -> () {
27 27 StorageLive(_5);
28 28 PlaceMention(_1);
29 29 _6 = discriminant(_1);
30 -switchInt(move _6) -> [1: bb4, otherwise: bb3];
30 +switchInt(move _6) -> [1: bb5, otherwise: bb4];
31 31 }
32 32
33 33 bb1: {
34 34 StorageLive(_3);
35 35 StorageLive(_4);
36 -_4 = begin_panic::<&str>(const "explicit panic") -> bb8;
36 +_4 = begin_panic::<&str>(const "explicit panic") -> bb9;
37 37 }
38 38
39 39 bb2: {
@@ -43,31 +43,35 @@ fn main() -> () {
43 43 }
44 44
45 45 bb3: {
46 -goto -> bb7;
46 +goto -> bb8;
47 47 }
48 48
49 49 bb4: {
50 -falseEdge -> [real: bb6, imaginary: bb3];
50 +goto -> bb3;
51 51 }
52 52
53 53 bb5: {
54 -goto -> bb3;
54 +falseEdge -> [real: bb7, imaginary: bb3];
55 55 }
56 56
57 57 bb6: {
58 +goto -> bb4;
59 +}
60 +
61 +bb7: {
58 62 _5 = ((_1 as Some).0: u8);
59 63 _0 = const ();
60 64 StorageDead(_5);
61 65 StorageDead(_1);
62 66 return;
63 67 }
64 68
65 -bb7: {
69 +bb8: {
66 70 StorageDead(_5);
67 71 goto -> bb1;
68 72 }
69 73
70 -bb8 (cleanup): {
74 +bb9 (cleanup): {
71 75 resume;
72 76 }
73 77 }
Original file line number Diff line number Diff line change
@@ -17,15 +17,15 @@ fn main() -> () {
17 17 }
18 18
19 19 bb1: {
20 -falseUnwind -> [real: bb2, unwind: bb14];
20 +falseUnwind -> [real: bb2, unwind: bb15];
21 21 }
22 22
23 23 bb2: {
24 24 StorageLive(_2);
25 25 StorageLive(_3);
26 26 _3 = const true;
27 27 PlaceMention(_3);
28 -switchInt(_3) -> [0: bb4, otherwise: bb6];
28 +switchInt(_3) -> [0: bb5, otherwise: bb7];
29 29 }
30 30
31 31 bb3: {
@@ -34,59 +34,63 @@ fn main() -> () {
34 34 }
35 35
36 36 bb4: {
37 -falseEdge -> [real: bb8, imaginary: bb6];
37 +goto -> bb3;
38 38 }
39 39
40 40 bb5: {
41 -goto -> bb3;
41 +falseEdge -> [real: bb9, imaginary: bb7];
42 42 }
43 43
44 44 bb6: {
45 -_0 = const ();
46 -goto -> bb13;
45 +goto -> bb4;
47 46 }
48 47
49 48 bb7: {
50 -goto -> bb3;
49 +_0 = const ();
50 +goto -> bb14;
51 51 }
52 52
53 53 bb8: {
54 -_2 = const 4_i32;
55 -goto -> bb11;
54 +goto -> bb4;
56 55 }
57 56
58 57 bb9: {
59 -unreachable;
58 +_2 = const 4_i32;
59 +goto -> bb12;
60 60 }
61 61
62 62 bb10: {
63 -goto -> bb11;
63 +unreachable;
64 64 }
65 65
66 66 bb11: {
67 +goto -> bb12;
68 +}
69 +
70 +bb12: {
67 71 FakeRead(ForLet(None), _2);
68 72 StorageDead(_3);
69 73 StorageLive(_5);
70 74 StorageLive(_6);
71 75 _6 = &_2;
72 -_5 = std::mem::drop::<&i32>(move _6) -> [return: bb12, unwind: bb14];
76 +_5 = std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb15];
73 77 }
74 78
75 -bb12: {
79 +bb13: {
76 80 StorageDead(_6);
77 81 StorageDead(_5);
78 82 _1 = const ();
79 83 StorageDead(_2);
80 84 goto -> bb1;
81 85 }
82 86
83 -bb13: {
87 +bb14: {
84 88 StorageDead(_3);
85 89 StorageDead(_2);
86 90 return;
87 91 }
88 92
89 -bb14 (cleanup): {
93 +bb15 (cleanup): {
90 94 resume;
91 95 }
92 96 }