Skip to content

Commit 00eec85

Browse files
committed
Emit diff instead of after mir in ElaborateDrops tests
to make it easy to understand chnages made by elaboration.
1 parent 07c993e commit 00eec85

8 files changed

+347
-326
lines changed

tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir

-70
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
- // MIR for `main` before ElaborateDrops
2+
+ // MIR for `main` after ElaborateDrops
3+
4+
fn main() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/issue_41110.rs:+0:11: +0:11
6+
let _1: (); // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
7+
let mut _2: S; // in scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
8+
let mut _3: S; // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
9+
let mut _4: S; // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
10+
+ let mut _5: bool; // in scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
11+
scope 1 {
12+
debug x => _1; // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
13+
}
14+
15+
bb0: {
16+
+ _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
17+
StorageLive(_1); // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
18+
StorageLive(_2); // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
19+
+ _5 = const true; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
20+
_2 = S; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
21+
StorageLive(_3); // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
22+
StorageLive(_4); // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
23+
_4 = S; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
24+
_3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
25+
// mir::Constant
26+
// + span: $DIR/issue_41110.rs:8:23: 8:25
27+
// + literal: Const { ty: fn(S) -> S {S::id}, val: Value(<ZST>) }
28+
}
29+
30+
bb1: {
31+
StorageDead(_4); // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
32+
+ _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
33+
_1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
34+
// mir::Constant
35+
// + span: $DIR/issue_41110.rs:8:15: 8:20
36+
// + literal: Const { ty: fn(S, S) {S::other}, val: Value(<ZST>) }
37+
}
38+
39+
bb2: {
40+
StorageDead(_3); // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
41+
+ _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
42+
StorageDead(_2); // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
43+
_0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:11: +2:2
44+
StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+2:1: +2:2
45+
return; // scope 0 at $DIR/issue_41110.rs:+2:2: +2:2
46+
}
47+
48+
bb3 (cleanup): {
49+
- drop(_3) -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
50+
+ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
51+
}
52+
53+
bb4 (cleanup): {
54+
- drop(_4) -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
55+
+ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
56+
}
57+
58+
bb5 (cleanup): {
59+
- drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
60+
+ goto -> bb8; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
61+
}
62+
63+
bb6 (cleanup): {
64+
resume; // scope 0 at $DIR/issue_41110.rs:+0:1: +2:2
65+
+ }
66+
+
67+
+ bb7 (cleanup): {
68+
+ drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
69+
+ }
70+
+
71+
+ bb8 (cleanup): {
72+
+ switchInt(_5) -> [0: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
73+
}
74+
}
75+

tests/mir-opt/issue_41110.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// check that we don't emit multiple drop flags when they are not needed.
44

55

6-
// EMIT_MIR issue_41110.main.ElaborateDrops.after.mir
6+
// EMIT_MIR issue_41110.main.ElaborateDrops.diff
77
fn main() {
88
let x = S.other(S.id());
99
}
1010

1111
// no_mangle to make sure this gets instantiated even in an executable.
1212
#[no_mangle]
13-
// EMIT_MIR issue_41110.test.ElaborateDrops.after.mir
13+
// EMIT_MIR issue_41110.test.ElaborateDrops.diff
1414
pub fn test() {
1515
let u = S;
1616
let mut v = S;

tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir

-101
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
- // MIR for `test` before ElaborateDrops
2+
+ // MIR for `test` after ElaborateDrops
3+
4+
fn test() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/issue_41110.rs:+0:15: +0:15
6+
let _1: S; // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
7+
let _3: (); // in scope 0 at $DIR/issue_41110.rs:+3:5: +3:12
8+
let mut _4: S; // in scope 0 at $DIR/issue_41110.rs:+3:10: +3:11
9+
let mut _5: S; // in scope 0 at $DIR/issue_41110.rs:+4:9: +4:10
10+
+ let mut _6: bool; // in scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
11+
scope 1 {
12+
debug u => _1; // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
13+
let mut _2: S; // in scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
14+
scope 2 {
15+
debug v => _2; // in scope 2 at $DIR/issue_41110.rs:+2:9: +2:14
16+
}
17+
}
18+
19+
bb0: {
20+
+ _6 = const false; // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
21+
StorageLive(_1); // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
22+
+ _6 = const true; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
23+
_1 = S; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
24+
StorageLive(_2); // scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
25+
_2 = S; // scope 1 at $DIR/issue_41110.rs:+2:17: +2:18
26+
StorageLive(_3); // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
27+
StorageLive(_4); // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
28+
_4 = move _2; // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
29+
_3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
30+
// mir::Constant
31+
// + span: $DIR/issue_41110.rs:17:5: 17:9
32+
// + literal: Const { ty: fn(S) {std::mem::drop::<S>}, val: Value(<ZST>) }
33+
}
34+
35+
bb1: {
36+
StorageDead(_4); // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
37+
StorageDead(_3); // scope 2 at $DIR/issue_41110.rs:+3:12: +3:13
38+
StorageLive(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
39+
+ _6 = const false; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
40+
_5 = move _1; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
41+
- replace(_2 <- move _5) -> [return: bb2, unwind: bb6]; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
42+
+ goto -> bb12; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
43+
}
44+
45+
bb2: {
46+
- drop(_5) -> [return: bb3, unwind: bb8]; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
47+
+ goto -> bb3; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
48+
}
49+
50+
bb3: {
51+
StorageDead(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
52+
_0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2
53+
drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
54+
}
55+
56+
bb4: {
57+
StorageDead(_2); // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
58+
- drop(_1) -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
59+
+ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
60+
}
61+
62+
bb5: {
63+
+ _6 = const false; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
64+
StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
65+
return; // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2
66+
}
67+
68+
bb6 (cleanup): {
69+
- drop(_5) -> bb8; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
70+
+ goto -> bb8; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
71+
}
72+
73+
bb7 (cleanup): {
74+
- drop(_4) -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
75+
+ goto -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
76+
}
77+
78+
bb8 (cleanup): {
79+
- drop(_2) -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
80+
+ goto -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
81+
}
82+
83+
bb9 (cleanup): {
84+
- drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
85+
+ goto -> bb14; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
86+
}
87+
88+
bb10 (cleanup): {
89+
resume; // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2
90+
+ }
91+
+
92+
+ bb11 (cleanup): {
93+
+ _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
94+
+ goto -> bb6; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
95+
+ }
96+
+
97+
+ bb12: {
98+
+ _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
99+
+ goto -> bb2; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
100+
+ }
101+
+
102+
+ bb13 (cleanup): {
103+
+ drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
104+
+ }
105+
+
106+
+ bb14 (cleanup): {
107+
+ switchInt(_6) -> [0: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
108+
}
109+
}
110+

0 commit comments

Comments
 (0)