Skip to content

Commit 864a65f

Browse files
committed
Update existing tests for or-patterns
1 parent ce1230a commit 864a65f

28 files changed

+344
-385
lines changed

src/test/mir-opt/const_prop/discriminant.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ fn main() {
1010
// ...
1111
// _3 = std::option::Option::<bool>::Some(const true,);
1212
// _4 = discriminant(_3);
13-
// switchInt(move _4) -> [1isize: bb3, otherwise: bb2];
13+
// switchInt(move _4) -> [1isize: bb2, otherwise: bb1];
1414
// }
1515
// bb1: {
16-
// _2 = const 42i32;
16+
// _2 = const 10i32;
1717
// goto -> bb4;
1818
// }
1919
// bb2: {
20-
// _2 = const 10i32;
21-
// goto -> bb4;
20+
// switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3];
2221
// }
2322
// bb3: {
24-
// switchInt(((_3 as Some).0: bool)) -> [false: bb2, otherwise: bb1];
23+
// _2 = const 42i32;
24+
// goto -> bb4;
2525
// }
2626
// bb4: {
2727
// _1 = Add(move _2, const 0i32);
@@ -33,18 +33,18 @@ fn main() {
3333
// ...
3434
// _3 = const Scalar(0x01) : std::option::Option<bool>;
3535
// _4 = const 1isize;
36-
// switchInt(const 1isize) -> [1isize: bb3, otherwise: bb2];
36+
// switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1];
3737
// }
3838
// bb1: {
39-
// _2 = const 42i32;
39+
// _2 = const 10i32;
4040
// goto -> bb4;
4141
// }
4242
// bb2: {
43-
// _2 = const 10i32;
44-
// goto -> bb4;
43+
// switchInt(const true) -> [false: bb1, otherwise: bb3];
4544
// }
4645
// bb3: {
47-
// switchInt(const true) -> [false: bb2, otherwise: bb1];
46+
// _2 = const 42i32;
47+
// goto -> bb4;
4848
// }
4949
// bb4: {
5050
// _1 = Add(move _2, const 0i32);

src/test/mir-opt/issue-62289.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,47 @@ fn main() {
3232
// bb2: {
3333
// StorageDead(_4);
3434
// _5 = discriminant(_3);
35-
// switchInt(move _5) -> [0isize: bb10, 1isize: bb5, otherwise: bb4];
35+
// switchInt(move _5) -> [0isize: bb4, 1isize: bb6, otherwise: bb5];
3636
// }
3737
// bb3 (cleanup): {
3838
// drop(_2) -> bb1;
3939
// }
4040
// bb4: {
41-
// unreachable;
41+
// StorageLive(_10);
42+
// _10 = ((_3 as Ok).0: u32);
43+
// (*_2) = _10;
44+
// StorageDead(_10);
45+
// _1 = move _2;
46+
// drop(_2) -> [return: bb12, unwind: bb11];
4247
// }
4348
// bb5: {
49+
// unreachable;
50+
// }
51+
// bb6: {
4452
// StorageLive(_6);
4553
// _6 = ((_3 as Err).0: std::option::NoneError);
4654
// StorageLive(_8);
4755
// StorageLive(_9);
4856
// _9 = _6;
49-
// _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb7, unwind: bb3];
57+
// _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb8, unwind: bb3];
5058
// }
51-
// bb6: {
59+
// bb7: {
5260
// return;
5361
// }
54-
// bb7: {
62+
// bb8: {
5563
// StorageDead(_9);
56-
// _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb8, unwind: bb3];
64+
// _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb9, unwind: bb3];
5765
// }
58-
// bb8: {
66+
// bb9: {
5967
// StorageDead(_8);
6068
// StorageDead(_6);
61-
// drop(_2) -> bb9;
69+
// drop(_2) -> bb10;
6270
// }
63-
// bb9: {
71+
// bb10: {
6472
// StorageDead(_2);
6573
// StorageDead(_1);
6674
// StorageDead(_3);
67-
// goto -> bb6;
68-
// }
69-
// bb10: {
70-
// StorageLive(_10);
71-
// _10 = ((_3 as Ok).0: u32);
72-
// (*_2) = _10;
73-
// StorageDead(_10);
74-
// _1 = move _2;
75-
// drop(_2) -> [return: bb12, unwind: bb11];
75+
// goto -> bb7;
7676
// }
7777
// bb11 (cleanup): {
7878
// drop(_1) -> bb1;
@@ -85,7 +85,7 @@ fn main() {
8585
// bb13: {
8686
// StorageDead(_1);
8787
// StorageDead(_3);
88-
// goto -> bb6;
88+
// goto -> bb7;
8989
// }
9090
// }
9191
// END rustc.test.ElaborateDrops.before.mir

src/test/mir-opt/match-arm-scopes.rs

+54-56
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ const CASES: &[(bool, bool, bool, i32)] = &[
2828

2929
fn main() {
3030
for &(cond, items_1, items_2, result) in CASES {
31-
assert_eq!(
32-
complicated_match(cond, (items_1, items_2, String::new())),
33-
result,
34-
);
31+
assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,);
3532
}
3633
}
3734

@@ -64,31 +61,38 @@ fn main() {
6461
// }
6562
// bb0: {
6663
// FakeRead(ForMatchedPlace, _2);
67-
// switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb5];
64+
// switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3];
6865
// }
6966
// bb1 (cleanup): {
7067
// resume;
7168
// }
72-
// bb2: {
73-
// falseEdges -> [real: bb8, imaginary: bb3];
69+
// bb2: { // pre-binding for arm 1 first pattern
70+
// falseEdges -> [real: bb9, imaginary: bb4];
7471
// }
7572
// bb3: {
76-
// falseEdges -> [real: bb17, imaginary: bb4];
73+
// switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5];
7774
// }
78-
// bb4: {
79-
// falseEdges -> [real: bb25, imaginary: bb26];
75+
// bb4: { // pre-binding for arm 1 second pattern
76+
// falseEdges -> [real: bb18, imaginary: bb6];
8077
// }
8178
// bb5: {
82-
// switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb6];
79+
// switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6];
8380
// }
84-
// bb6: {
85-
// switchInt((_2.0: bool)) -> [false: bb26, otherwise: bb4];
81+
// bb6: { // pre-binding for arm 2 first pattern
82+
// falseEdges -> [real: bb26, imaginary: bb7];
8683
// }
87-
// bb7: { // arm 1
84+
// bb7: { // bindings for arm 2 - second pattern
85+
// StorageLive(_15);
86+
// _15 = (_2.1: bool);
87+
// StorageLive(_16);
88+
// _16 = move (_2.2: std::string::String);
89+
// goto -> bb25;
90+
// }
91+
// bb8: { // arm 1
8892
// _0 = const 1i32;
89-
// drop(_7) -> [return: bb23, unwind: bb13];
93+
// drop(_7) -> [return: bb24, unwind: bb14];
9094
// }
91-
// bb8: { // guard - first time
95+
// bb9: { // guard - first time
9296
// StorageLive(_6);
9397
// _6 = &(_2.1: bool);
9498
// StorageLive(_8);
@@ -99,34 +103,34 @@ fn main() {
99103
// StorageLive(_10);
100104
// _10 = _1;
101105
// FakeRead(ForMatchedPlace, _10);
102-
// switchInt(_10) -> [false: bb10, otherwise: bb9];
106+
// switchInt(_10) -> [false: bb11, otherwise: bb10];
103107
// }
104-
// bb9: {
105-
// falseEdges -> [real: bb11, imaginary: bb10];
108+
// bb10: {
109+
// falseEdges -> [real: bb12, imaginary: bb11];
106110
// }
107-
// bb10: { // `else` block - first time
111+
// bb11: { // `else` block - first time
108112
// _9 = (*_6);
109113
// StorageDead(_10);
110-
// switchInt(move _9) -> [false: bb16, otherwise: bb15];
114+
// switchInt(move _9) -> [false: bb17, otherwise: bb16];
111115
// }
112-
// bb11: { // `return 3` - first time
116+
// bb12: { // `return 3` - first time
113117
// _0 = const 3i32;
114118
// StorageDead(_10);
115119
// StorageDead(_9);
116120
// StorageDead(_8);
117121
// StorageDead(_6);
118-
// goto -> bb14;
122+
// goto -> bb15;
119123
// }
120-
// bb12: {
124+
// bb13: {
121125
// return;
122126
// }
123-
// bb13 (cleanup): {
127+
// bb14 (cleanup): {
124128
// drop(_2) -> bb1;
125129
// }
126-
// bb14: {
127-
// drop(_2) -> [return: bb12, unwind: bb1];
128-
// }
129130
// bb15: {
131+
// drop(_2) -> [return: bb13, unwind: bb1];
132+
// }
133+
// bb16: {
130134
// StorageDead(_9);
131135
// FakeRead(ForMatchGuard, _3);
132136
// FakeRead(ForMatchGuard, _4);
@@ -136,15 +140,15 @@ fn main() {
136140
// _5 = (_2.1: bool);
137141
// StorageLive(_7);
138142
// _7 = move (_2.2: std::string::String);
139-
// goto -> bb7;
143+
// goto -> bb8;
140144
// }
141-
// bb16: { // guard otherwise case - first time
145+
// bb17: { // guard otherwise case - first time
142146
// StorageDead(_9);
143147
// StorageDead(_8);
144148
// StorageDead(_6);
145-
// falseEdges -> [real: bb5, imaginary: bb3];
149+
// falseEdges -> [real: bb3, imaginary: bb4];
146150
// }
147-
// bb17: { // guard - second time
151+
// bb18: { // guard - second time
148152
// StorageLive(_6);
149153
// _6 = &(_2.0: bool);
150154
// StorageLive(_8);
@@ -155,25 +159,25 @@ fn main() {
155159
// StorageLive(_13);
156160
// _13 = _1;
157161
// FakeRead(ForMatchedPlace, _13);
158-
// switchInt(_13) -> [false: bb19, otherwise: bb18];
162+
// switchInt(_13) -> [false: bb20, otherwise: bb19];
159163
// }
160-
// bb18: {
161-
// falseEdges -> [real: bb20, imaginary: bb19];
164+
// bb19: {
165+
// falseEdges -> [real: bb21, imaginary: bb20];
162166
// }
163-
// bb19: { // `else` block - second time
167+
// bb20: { // `else` block - second time
164168
// _12 = (*_6);
165169
// StorageDead(_13);
166-
// switchInt(move _12) -> [false: bb22, otherwise: bb21];
170+
// switchInt(move _12) -> [false: bb23, otherwise: bb22];
167171
// }
168-
// bb20: {
172+
// bb21: {
169173
// _0 = const 3i32;
170174
// StorageDead(_13);
171175
// StorageDead(_12);
172176
// StorageDead(_8);
173177
// StorageDead(_6);
174-
// goto -> bb14;
178+
// goto -> bb15;
175179
// }
176-
// bb21: { // bindings for arm 1
180+
// bb22: { // bindings for arm 1
177181
// StorageDead(_12);
178182
// FakeRead(ForMatchGuard, _3);
179183
// FakeRead(ForMatchGuard, _4);
@@ -183,46 +187,40 @@ fn main() {
183187
// _5 = (_2.0: bool);
184188
// StorageLive(_7);
185189
// _7 = move (_2.2: std::string::String);
186-
// goto -> bb7;
190+
// goto -> bb8;
187191
// }
188-
// bb22: { // Guard otherwise case - second time
192+
// bb23: { // Guard otherwise case - second time
189193
// StorageDead(_12);
190194
// StorageDead(_8);
191195
// StorageDead(_6);
192-
// falseEdges -> [real: bb6, imaginary: bb4];
196+
// falseEdges -> [real: bb5, imaginary: bb6];
193197
// }
194-
// bb23: { // rest of arm 1
198+
// bb24: { // rest of arm 1
195199
// StorageDead(_7);
196200
// StorageDead(_5);
197201
// StorageDead(_8);
198202
// StorageDead(_6);
199203
// goto -> bb28;
200204
// }
201-
// bb24: { // arm 2
205+
// bb25: { // arm 2
202206
// _0 = const 2i32;
203-
// drop(_16) -> [return: bb27, unwind: bb13];
207+
// drop(_16) -> [return: bb27, unwind: bb14];
204208
// }
205-
// bb25: { // bindings for arm 2 - first pattern
209+
// bb26: { // bindings for arm 2 - first pattern
206210
// StorageLive(_15);
207211
// _15 = (_2.1: bool);
208212
// StorageLive(_16);
209213
// _16 = move (_2.2: std::string::String);
210-
// goto -> bb24;
211-
// }
212-
// bb26: { // bindings for arm 2 - second pattern
213-
// StorageLive(_15);
214-
// _15 = (_2.1: bool);
215-
// StorageLive(_16);
216-
// _16 = move (_2.2: std::string::String);
217-
// goto -> bb24;
214+
// goto -> bb25;
218215
// }
216+
219217
// bb27: { // rest of arm 2
220218
// StorageDead(_16);
221219
// StorageDead(_15);
222220
// goto -> bb28;
223221
// }
224222
// bb28: {
225-
// drop(_2) -> [return: bb12, unwind: bb1];
223+
// drop(_2) -> [return: bb13, unwind: bb1];
226224
// }
227225
// END rustc.complicated_match.SimplifyCfg-initial.after.mir
228226
// START rustc.complicated_match.ElaborateDrops.after.mir

0 commit comments

Comments
 (0)