Skip to content

Commit de73af9

Browse files
committed
Add test.
1 parent f018b46 commit de73af9

8 files changed

+724
-1
lines changed
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// MIR for `const_array_len` after built
2+
3+
fn const_array_len(_1: [T; 5]) -> () {
4+
debug x => _1;
5+
let mut _0: ();
6+
let _6: ();
7+
let mut _7: T;
8+
let _8: ();
9+
let mut _9: T;
10+
let _10: ();
11+
let mut _11: [T; 2];
12+
let _12: ();
13+
let mut _13: T;
14+
scope 1 {
15+
debug a => _2;
16+
debug b => _3;
17+
debug rest => _4;
18+
debug e => _5;
19+
let _2: T;
20+
let _3: T;
21+
let _4: [T; 2];
22+
let _5: T;
23+
}
24+
25+
bb0: {
26+
PlaceMention(_1);
27+
falseEdge -> [real: bb2, imaginary: bb1];
28+
}
29+
30+
bb1: {
31+
goto -> bb7;
32+
}
33+
34+
bb2: {
35+
StorageLive(_2);
36+
_2 = move _1[0 of 5];
37+
StorageLive(_3);
38+
_3 = move _1[1 of 5];
39+
StorageLive(_4);
40+
_4 = move _1[2..4];
41+
StorageLive(_5);
42+
_5 = move _1[4 of 5];
43+
StorageLive(_6);
44+
StorageLive(_7);
45+
_7 = move _2;
46+
_6 = opaque::<T>(move _7) -> [return: bb3, unwind: bb17];
47+
}
48+
49+
bb3: {
50+
StorageDead(_7);
51+
StorageDead(_6);
52+
StorageLive(_8);
53+
StorageLive(_9);
54+
_9 = move _3;
55+
_8 = opaque::<T>(move _9) -> [return: bb4, unwind: bb16];
56+
}
57+
58+
bb4: {
59+
StorageDead(_9);
60+
StorageDead(_8);
61+
StorageLive(_10);
62+
StorageLive(_11);
63+
_11 = move _4;
64+
_10 = opaque::<[T; 2]>(move _11) -> [return: bb5, unwind: bb15];
65+
}
66+
67+
bb5: {
68+
StorageDead(_11);
69+
StorageDead(_10);
70+
StorageLive(_12);
71+
StorageLive(_13);
72+
_13 = move _5;
73+
_12 = opaque::<T>(move _13) -> [return: bb6, unwind: bb14];
74+
}
75+
76+
bb6: {
77+
StorageDead(_13);
78+
StorageDead(_12);
79+
_0 = const ();
80+
drop(_5) -> [return: bb8, unwind: bb19];
81+
}
82+
83+
bb7: {
84+
_0 = const ();
85+
goto -> bb12;
86+
}
87+
88+
bb8: {
89+
StorageDead(_5);
90+
drop(_4) -> [return: bb9, unwind: bb20];
91+
}
92+
93+
bb9: {
94+
StorageDead(_4);
95+
drop(_3) -> [return: bb10, unwind: bb21];
96+
}
97+
98+
bb10: {
99+
StorageDead(_3);
100+
drop(_2) -> [return: bb11, unwind: bb22];
101+
}
102+
103+
bb11: {
104+
StorageDead(_2);
105+
goto -> bb12;
106+
}
107+
108+
bb12: {
109+
drop(_1) -> [return: bb13, unwind: bb23];
110+
}
111+
112+
bb13: {
113+
return;
114+
}
115+
116+
bb14 (cleanup): {
117+
drop(_13) -> [return: bb18, unwind terminate(cleanup)];
118+
}
119+
120+
bb15 (cleanup): {
121+
drop(_11) -> [return: bb18, unwind terminate(cleanup)];
122+
}
123+
124+
bb16 (cleanup): {
125+
drop(_9) -> [return: bb18, unwind terminate(cleanup)];
126+
}
127+
128+
bb17 (cleanup): {
129+
drop(_7) -> [return: bb18, unwind terminate(cleanup)];
130+
}
131+
132+
bb18 (cleanup): {
133+
drop(_5) -> [return: bb19, unwind terminate(cleanup)];
134+
}
135+
136+
bb19 (cleanup): {
137+
drop(_4) -> [return: bb20, unwind terminate(cleanup)];
138+
}
139+
140+
bb20 (cleanup): {
141+
drop(_3) -> [return: bb21, unwind terminate(cleanup)];
142+
}
143+
144+
bb21 (cleanup): {
145+
drop(_2) -> [return: bb22, unwind terminate(cleanup)];
146+
}
147+
148+
bb22 (cleanup): {
149+
drop(_1) -> [return: bb23, unwind terminate(cleanup)];
150+
}
151+
152+
bb23 (cleanup): {
153+
resume;
154+
}
155+
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// MIR for `const_array_len` after built
2+
3+
fn const_array_len(_1: [T; 5]) -> () {
4+
debug x => _1;
5+
let mut _0: ();
6+
let _6: ();
7+
let mut _7: T;
8+
let _8: ();
9+
let mut _9: T;
10+
let _10: ();
11+
let mut _11: [T; 2];
12+
let _12: ();
13+
let mut _13: T;
14+
scope 1 {
15+
debug a => _2;
16+
debug b => _3;
17+
debug rest => _4;
18+
debug e => _5;
19+
let _2: T;
20+
let _3: T;
21+
let _4: [T; 2];
22+
let _5: T;
23+
}
24+
25+
bb0: {
26+
PlaceMention(_1);
27+
falseEdge -> [real: bb2, imaginary: bb1];
28+
}
29+
30+
bb1: {
31+
goto -> bb7;
32+
}
33+
34+
bb2: {
35+
StorageLive(_2);
36+
_2 = move _1[0 of 5];
37+
StorageLive(_3);
38+
_3 = move _1[1 of 5];
39+
StorageLive(_4);
40+
_4 = move _1[2..4];
41+
StorageLive(_5);
42+
_5 = move _1[4 of 5];
43+
StorageLive(_6);
44+
StorageLive(_7);
45+
_7 = move _2;
46+
_6 = opaque::<T>(move _7) -> [return: bb3, unwind: bb17];
47+
}
48+
49+
bb3: {
50+
StorageDead(_7);
51+
StorageDead(_6);
52+
StorageLive(_8);
53+
StorageLive(_9);
54+
_9 = move _3;
55+
_8 = opaque::<T>(move _9) -> [return: bb4, unwind: bb16];
56+
}
57+
58+
bb4: {
59+
StorageDead(_9);
60+
StorageDead(_8);
61+
StorageLive(_10);
62+
StorageLive(_11);
63+
_11 = move _4;
64+
_10 = opaque::<[T; 2]>(move _11) -> [return: bb5, unwind: bb15];
65+
}
66+
67+
bb5: {
68+
StorageDead(_11);
69+
StorageDead(_10);
70+
StorageLive(_12);
71+
StorageLive(_13);
72+
_13 = move _5;
73+
_12 = opaque::<T>(move _13) -> [return: bb6, unwind: bb14];
74+
}
75+
76+
bb6: {
77+
StorageDead(_13);
78+
StorageDead(_12);
79+
_0 = const ();
80+
drop(_5) -> [return: bb8, unwind: bb19];
81+
}
82+
83+
bb7: {
84+
_0 = const ();
85+
goto -> bb12;
86+
}
87+
88+
bb8: {
89+
StorageDead(_5);
90+
drop(_4) -> [return: bb9, unwind: bb20];
91+
}
92+
93+
bb9: {
94+
StorageDead(_4);
95+
drop(_3) -> [return: bb10, unwind: bb21];
96+
}
97+
98+
bb10: {
99+
StorageDead(_3);
100+
drop(_2) -> [return: bb11, unwind: bb22];
101+
}
102+
103+
bb11: {
104+
StorageDead(_2);
105+
goto -> bb12;
106+
}
107+
108+
bb12: {
109+
drop(_1) -> [return: bb13, unwind: bb23];
110+
}
111+
112+
bb13: {
113+
return;
114+
}
115+
116+
bb14 (cleanup): {
117+
drop(_13) -> [return: bb18, unwind terminate(cleanup)];
118+
}
119+
120+
bb15 (cleanup): {
121+
drop(_11) -> [return: bb18, unwind terminate(cleanup)];
122+
}
123+
124+
bb16 (cleanup): {
125+
drop(_9) -> [return: bb18, unwind terminate(cleanup)];
126+
}
127+
128+
bb17 (cleanup): {
129+
drop(_7) -> [return: bb18, unwind terminate(cleanup)];
130+
}
131+
132+
bb18 (cleanup): {
133+
drop(_5) -> [return: bb19, unwind terminate(cleanup)];
134+
}
135+
136+
bb19 (cleanup): {
137+
drop(_4) -> [return: bb20, unwind terminate(cleanup)];
138+
}
139+
140+
bb20 (cleanup): {
141+
drop(_3) -> [return: bb21, unwind terminate(cleanup)];
142+
}
143+
144+
bb21 (cleanup): {
145+
drop(_2) -> [return: bb22, unwind terminate(cleanup)];
146+
}
147+
148+
bb22 (cleanup): {
149+
drop(_1) -> [return: bb23, unwind terminate(cleanup)];
150+
}
151+
152+
bb23 (cleanup): {
153+
resume;
154+
}
155+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2+
//@ compile-flags: -Zmir-opt-level=0
3+
4+
fn opaque<T>(x: T) {}
5+
6+
// EMIT_MIR array_len.const_array_len.built.after.mir
7+
fn const_array_len<T>(x: [T; 5]) {
8+
// CHECK-LABEL: fn const_array_len(
9+
// CHECK-NOT: Len
10+
// CHECK-NOT: PtrMetadata
11+
// CHECK: = const 5_usize;
12+
if let [a, b, rest @ .., e] = x {
13+
opaque(a);
14+
opaque(b);
15+
opaque(rest);
16+
opaque(e);
17+
}
18+
}
19+
20+
// EMIT_MIR array_len.slice_len.built.after.mir
21+
fn slice_len<T>(x: &[T]) {
22+
// CHECK-LABEL: fn slice_len(
23+
// CHECK-NOT: Len
24+
// CHECK: = PtrMetadata(copy _1);
25+
if let [a, b, rest @ .., e] = x {
26+
opaque(a);
27+
opaque(b);
28+
opaque(rest);
29+
opaque(e);
30+
}
31+
}

0 commit comments

Comments
 (0)