Skip to content

Commit 7e62406

Browse files
authored
Rollup merge of #101428 - JakobDegen:build-tests, r=oli-obk
Add mir building test directory The first commit renames `mir-map.0` mir dumps to `built.after` dumps. I am happy to drop this commit if someone can explain the origin of the name. The second commit moves a bunch of mir building tests into their own directory. I did my best to make sure that all of these tests are actually testing mir building, and not just incidentally using `built.after` r? ``@oli-obk``
2 parents 9911229 + 51b0363 commit 7e62406

File tree

52 files changed

+136
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+136
-112
lines changed

compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ fn mir_const<'tcx>(
288288

289289
let mut body = tcx.mir_built(def).steal();
290290

291-
rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
291+
pass_manager::dump_mir_for_phase_change(tcx, &body);
292292

293293
pm::run_passes(
294294
tcx,

compiler/rustc_mir_transform/src/shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
845845
span,
846846
);
847847

848-
rustc_middle::mir::dump_mir(tcx, None, "mir_map", &0, &body, |_, _| Ok(()));
848+
crate::pass_manager::dump_mir_for_phase_change(tcx, &body);
849849

850850
body
851851
}

src/test/mir-opt/enum_cast.bar.mir_map.0.mir renamed to src/test/mir-opt/building/enum_cast.bar.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `bar` 0 mir_map
1+
// MIR for `bar` after built
22

33
fn bar(_1: Bar) -> usize {
44
debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11

src/test/mir-opt/enum_cast.boo.mir_map.0.mir renamed to src/test/mir-opt/building/enum_cast.boo.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `boo` 0 mir_map
1+
// MIR for `boo` after built
22

33
fn boo(_1: Boo) -> usize {
44
debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11

src/test/mir-opt/enum_cast.droppy.mir_map.0.mir renamed to src/test/mir-opt/building/enum_cast.droppy.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `droppy` 0 mir_map
1+
// MIR for `droppy` after built
22

33
fn droppy() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/enum_cast.rs:+0:13: +0:13

src/test/mir-opt/enum_cast.foo.mir_map.0.mir renamed to src/test/mir-opt/building/enum_cast.foo.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `foo` 0 mir_map
1+
// MIR for `foo` after built
22

33
fn foo(_1: Foo) -> usize {
44
debug foo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11

src/test/mir-opt/enum_cast.rs renamed to src/test/mir-opt/building/enum_cast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// EMIT_MIR enum_cast.foo.mir_map.0.mir
2-
// EMIT_MIR enum_cast.bar.mir_map.0.mir
3-
// EMIT_MIR enum_cast.boo.mir_map.0.mir
1+
// EMIT_MIR enum_cast.foo.built.after.mir
2+
// EMIT_MIR enum_cast.bar.built.after.mir
3+
// EMIT_MIR enum_cast.boo.built.after.mir
44

55
enum Foo {
66
A
@@ -27,7 +27,7 @@ fn boo(boo: Boo) -> usize {
2727
boo as usize
2828
}
2929

30-
// EMIT_MIR enum_cast.droppy.mir_map.0.mir
30+
// EMIT_MIR enum_cast.droppy.built.after.mir
3131
enum Droppy {
3232
A, B, C
3333
}

src/test/mir-opt/issue-101867.rs renamed to src/test/mir-opt/building/issue-101867.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR issue_101867.main.mir_map.0.mir
1+
// EMIT_MIR issue_101867.main.built.after.mir
22
fn main() {
33
let x: Option<u8> = Some(1);
44
let Some(y) = x else {

src/test/mir-opt/issue-49232.rs renamed to src/test/mir-opt/building/issue-49232.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// We must mark a variable whose initialization fails due to an
22
// abort statement as StorageDead.
33

4-
// EMIT_MIR issue_49232.main.mir_map.0.mir
4+
// EMIT_MIR issue_49232.main.built.after.mir
55
fn main() {
66
loop {
77
let beacon = {

src/test/mir-opt/issue_101867.main.mir_map.0.mir renamed to src/test/mir-opt/building/issue_101867.main.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `main` 0 mir_map
1+
// MIR for `main` after built
22

33
| User Type Annotations
44
| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8>

src/test/mir-opt/issue_49232.main.mir_map.0.mir renamed to src/test/mir-opt/building/issue_49232.main.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `main` 0 mir_map
1+
// MIR for `main` after built
22

33
fn main() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/issue-49232.rs:+0:11: +0:11

src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir renamed to src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `full_tested_match` after PromoteTemps
1+
// MIR for `full_tested_match` after built
22

33
fn full_tested_match() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:28: +0:28
@@ -12,7 +12,6 @@ fn full_tested_match() -> () {
1212
let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36
1313
let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
1414
let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:24: +3:25
15-
let mut _11: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
1615
scope 1 {
1716
}
1817
scope 2 {
@@ -34,15 +33,15 @@ fn full_tested_match() -> () {
3433

3534
bb1: {
3635
_1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
37-
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
36+
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
3837
}
3938

4039
bb2: {
4140
falseEdge -> [real: bb5, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16
4241
}
4342

4443
bb3: {
45-
falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16
44+
falseEdge -> [real: bb10, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16
4645
}
4746

4847
bb4: {
@@ -51,14 +50,10 @@ fn full_tested_match() -> () {
5150

5251
bb5: {
5352
StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
54-
_11 = const _; // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
55-
// mir::Constant
56-
// + span: $DIR/match_false_edges.rs:14:14: 14:15
57-
// + literal: Const { ty: &Option<i32>, val: Unevaluated(full_tested_match, [], Some(promoted[0])) }
58-
_6 = &(((*_11) as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
53+
_6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
5954
_4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
6055
StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
61-
_7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
56+
_7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
6257
// mir::Constant
6358
// + span: $DIR/match_false_edges.rs:14:20: 14:25
6459
// + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
@@ -80,34 +75,38 @@ fn full_tested_match() -> () {
8075
StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37
8176
StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
8277
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
83-
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
78+
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
8479
}
8580

8681
bb8: {
82+
goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
83+
}
84+
85+
bb9: {
8786
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
8887
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
8988
goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
9089
}
9190

92-
bb9: {
91+
bb10: {
9392
StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
9493
_9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
9594
StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25
9695
_10 = _9; // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25
9796
_1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+3:20: +3:26
9897
StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+3:25: +3:26
9998
StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
100-
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
99+
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
101100
}
102101

103-
bb10: {
102+
bb11: {
104103
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
105104
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
106105
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2
107106
return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2
108107
}
109108

110-
bb11 (cleanup): {
109+
bb12 (cleanup): {
111110
resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2
112111
}
113112
}

src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir renamed to src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `full_tested_match2` before PromoteTemps
1+
// MIR for `full_tested_match2` after built
22

33
fn full_tested_match2() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:29: +0:29
@@ -32,7 +32,7 @@ fn full_tested_match2() -> () {
3232
}
3333

3434
bb1: {
35-
falseEdge -> [real: bb9, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13
35+
falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13
3636
}
3737

3838
bb2: {
@@ -47,7 +47,7 @@ fn full_tested_match2() -> () {
4747
_1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+4:20: +4:26
4848
StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+4:25: +4:26
4949
StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
50-
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
50+
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
5151
}
5252

5353
bb4: {
@@ -59,7 +59,7 @@ fn full_tested_match2() -> () {
5959
_6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
6060
_4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
6161
StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
62-
_7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
62+
_7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
6363
// mir::Constant
6464
// + span: $DIR/match_false_edges.rs:25:20: 25:25
6565
// + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
@@ -81,28 +81,32 @@ fn full_tested_match2() -> () {
8181
StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37
8282
StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
8383
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
84-
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
84+
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
8585
}
8686

8787
bb8: {
88+
goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
89+
}
90+
91+
bb9: {
8892
StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
8993
StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
9094
falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
9195
}
9296

93-
bb9: {
97+
bb10: {
9498
_1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
95-
goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
99+
goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
96100
}
97101

98-
bb10: {
102+
bb11: {
99103
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
100104
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
101105
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2
102106
return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2
103107
}
104108

105-
bb11 (cleanup): {
109+
bb12 (cleanup): {
106110
resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2
107111
}
108112
}

0 commit comments

Comments
 (0)