Skip to content

Commit 0cd52bb

Browse files
committed
Update the tests to cover const contexts as well
1 parent c484e27 commit 0cd52bb

11 files changed

Lines changed: 1048 additions & 0 deletions
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// MIR for `const_array_match` after built
2+
3+
fn const_array_match(_1: [u8; 4]) -> bool {
4+
debug x => _1;
5+
let mut _0: bool;
6+
scope 1 {
7+
}
8+
9+
bb0: {
10+
PlaceMention(_1);
11+
switchInt(copy _1[0 of 4]) -> [1: bb2, otherwise: bb1];
12+
}
13+
14+
bb1: {
15+
_0 = const false;
16+
goto -> bb12;
17+
}
18+
19+
bb2: {
20+
switchInt(copy _1[1 of 4]) -> [2: bb4, otherwise: bb3];
21+
}
22+
23+
bb3: {
24+
goto -> bb1;
25+
}
26+
27+
bb4: {
28+
switchInt(copy _1[2 of 4]) -> [3: bb6, otherwise: bb5];
29+
}
30+
31+
bb5: {
32+
goto -> bb3;
33+
}
34+
35+
bb6: {
36+
switchInt(copy _1[3 of 4]) -> [4: bb8, otherwise: bb7];
37+
}
38+
39+
bb7: {
40+
goto -> bb5;
41+
}
42+
43+
bb8: {
44+
falseEdge -> [real: bb11, imaginary: bb1];
45+
}
46+
47+
bb9: {
48+
goto -> bb7;
49+
}
50+
51+
bb10: {
52+
FakeRead(ForMatchedPlace(None), _1);
53+
unreachable;
54+
}
55+
56+
bb11: {
57+
_0 = const true;
58+
goto -> bb12;
59+
}
60+
61+
bb12: {
62+
return;
63+
}
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// MIR for `const_array_match` after built
2+
3+
fn const_array_match(_1: [u8; 4]) -> bool {
4+
debug x => _1;
5+
let mut _0: bool;
6+
scope 1 {
7+
}
8+
9+
bb0: {
10+
PlaceMention(_1);
11+
switchInt(copy _1[0 of 4]) -> [1: bb2, otherwise: bb1];
12+
}
13+
14+
bb1: {
15+
_0 = const false;
16+
goto -> bb12;
17+
}
18+
19+
bb2: {
20+
switchInt(copy _1[1 of 4]) -> [2: bb4, otherwise: bb3];
21+
}
22+
23+
bb3: {
24+
goto -> bb1;
25+
}
26+
27+
bb4: {
28+
switchInt(copy _1[2 of 4]) -> [3: bb6, otherwise: bb5];
29+
}
30+
31+
bb5: {
32+
goto -> bb3;
33+
}
34+
35+
bb6: {
36+
switchInt(copy _1[3 of 4]) -> [4: bb8, otherwise: bb7];
37+
}
38+
39+
bb7: {
40+
goto -> bb5;
41+
}
42+
43+
bb8: {
44+
falseEdge -> [real: bb11, imaginary: bb1];
45+
}
46+
47+
bb9: {
48+
goto -> bb7;
49+
}
50+
51+
bb10: {
52+
FakeRead(ForMatchedPlace(None), _1);
53+
unreachable;
54+
}
55+
56+
bb11: {
57+
_0 = const true;
58+
goto -> bb12;
59+
}
60+
61+
bb12: {
62+
return;
63+
}
64+
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
// MIR for `const_try_from_matched` after built
2+
3+
fn const_try_from_matched(_1: [u8; 4]) -> Result<MyEnum, ()> {
4+
debug value => _1;
5+
let mut _0: std::result::Result<MyEnum, ()>;
6+
let mut _2: &[u8; 4];
7+
let mut _3: MyEnum;
8+
let mut _4: MyEnum;
9+
let mut _5: MyEnum;
10+
let mut _6: MyEnum;
11+
let mut _7: ();
12+
13+
bb0: {
14+
StorageLive(_2);
15+
_2 = &_1;
16+
PlaceMention(_2);
17+
switchInt(copy (*_2)[0 of 4]) -> [65: bb2, 69: bb10, 73: bb18, 77: bb26, otherwise: bb1];
18+
}
19+
20+
bb1: {
21+
StorageLive(_7);
22+
_7 = ();
23+
_0 = Result::<MyEnum, ()>::Err(move _7);
24+
StorageDead(_7);
25+
goto -> bb39;
26+
}
27+
28+
bb2: {
29+
switchInt(copy (*_2)[1 of 4]) -> [66: bb4, otherwise: bb3];
30+
}
31+
32+
bb3: {
33+
goto -> bb1;
34+
}
35+
36+
bb4: {
37+
switchInt(copy (*_2)[2 of 4]) -> [67: bb6, otherwise: bb5];
38+
}
39+
40+
bb5: {
41+
goto -> bb3;
42+
}
43+
44+
bb6: {
45+
switchInt(copy (*_2)[3 of 4]) -> [68: bb8, otherwise: bb7];
46+
}
47+
48+
bb7: {
49+
goto -> bb5;
50+
}
51+
52+
bb8: {
53+
falseEdge -> [real: bb38, imaginary: bb10];
54+
}
55+
56+
bb9: {
57+
goto -> bb7;
58+
}
59+
60+
bb10: {
61+
switchInt(copy (*_2)[1 of 4]) -> [70: bb12, otherwise: bb11];
62+
}
63+
64+
bb11: {
65+
goto -> bb1;
66+
}
67+
68+
bb12: {
69+
switchInt(copy (*_2)[2 of 4]) -> [71: bb14, otherwise: bb13];
70+
}
71+
72+
bb13: {
73+
goto -> bb11;
74+
}
75+
76+
bb14: {
77+
switchInt(copy (*_2)[3 of 4]) -> [72: bb16, otherwise: bb15];
78+
}
79+
80+
bb15: {
81+
goto -> bb13;
82+
}
83+
84+
bb16: {
85+
falseEdge -> [real: bb37, imaginary: bb18];
86+
}
87+
88+
bb17: {
89+
goto -> bb15;
90+
}
91+
92+
bb18: {
93+
switchInt(copy (*_2)[1 of 4]) -> [74: bb20, otherwise: bb19];
94+
}
95+
96+
bb19: {
97+
goto -> bb1;
98+
}
99+
100+
bb20: {
101+
switchInt(copy (*_2)[2 of 4]) -> [75: bb22, otherwise: bb21];
102+
}
103+
104+
bb21: {
105+
goto -> bb19;
106+
}
107+
108+
bb22: {
109+
switchInt(copy (*_2)[3 of 4]) -> [76: bb24, otherwise: bb23];
110+
}
111+
112+
bb23: {
113+
goto -> bb21;
114+
}
115+
116+
bb24: {
117+
falseEdge -> [real: bb36, imaginary: bb26];
118+
}
119+
120+
bb25: {
121+
goto -> bb23;
122+
}
123+
124+
bb26: {
125+
switchInt(copy (*_2)[1 of 4]) -> [78: bb28, otherwise: bb27];
126+
}
127+
128+
bb27: {
129+
goto -> bb1;
130+
}
131+
132+
bb28: {
133+
switchInt(copy (*_2)[2 of 4]) -> [79: bb30, otherwise: bb29];
134+
}
135+
136+
bb29: {
137+
goto -> bb27;
138+
}
139+
140+
bb30: {
141+
switchInt(copy (*_2)[3 of 4]) -> [80: bb32, otherwise: bb31];
142+
}
143+
144+
bb31: {
145+
goto -> bb29;
146+
}
147+
148+
bb32: {
149+
falseEdge -> [real: bb35, imaginary: bb1];
150+
}
151+
152+
bb33: {
153+
goto -> bb31;
154+
}
155+
156+
bb34: {
157+
FakeRead(ForMatchedPlace(None), _2);
158+
unreachable;
159+
}
160+
161+
bb35: {
162+
StorageLive(_6);
163+
_6 = MyEnum::D;
164+
_0 = Result::<MyEnum, ()>::Ok(move _6);
165+
StorageDead(_6);
166+
goto -> bb39;
167+
}
168+
169+
bb36: {
170+
StorageLive(_5);
171+
_5 = MyEnum::C;
172+
_0 = Result::<MyEnum, ()>::Ok(move _5);
173+
StorageDead(_5);
174+
goto -> bb39;
175+
}
176+
177+
bb37: {
178+
StorageLive(_4);
179+
_4 = MyEnum::B;
180+
_0 = Result::<MyEnum, ()>::Ok(move _4);
181+
StorageDead(_4);
182+
goto -> bb39;
183+
}
184+
185+
bb38: {
186+
StorageLive(_3);
187+
_3 = MyEnum::A;
188+
_0 = Result::<MyEnum, ()>::Ok(move _3);
189+
StorageDead(_3);
190+
goto -> bb39;
191+
}
192+
193+
bb39: {
194+
StorageDead(_2);
195+
return;
196+
}
197+
}

0 commit comments

Comments
 (0)