Skip to content

Commit 426183c

Browse files
committed
Update README and tests for new infrastructure
1 parent a5e8a0e commit 426183c

25 files changed

+304
-73
lines changed

Diff for: src/test/mir-opt/README.md

+24-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ The test format is:
77
// END RUST SOURCE
88
// START $file_name_of_some_mir_dump_0
99
// $expected_line_0
10-
// ...
10+
// (lines or elision)
1111
// $expected_line_N
1212
// END $file_name_of_some_mir_dump_0
13-
// ...
13+
// (lines or elision)
1414
// START $file_name_of_some_mir_dump_N
1515
// $expected_line_0
16-
// ...
16+
// (lines or elision)
1717
// $expected_line_N
1818
// END $file_name_of_some_mir_dump_N
1919
```
@@ -22,10 +22,15 @@ All the test information is in comments so the test is runnable.
2222

2323
For each $file_name, compiletest expects [$expected_line_0, ...,
2424
$expected_line_N] to appear in the dumped MIR in order. Currently it allows
25-
other non-matched lines before, after and in-between. Note that this includes
26-
lines that end basic blocks or begin new ones; it is good practice
27-
in your tests to include the terminator for each of your basic blocks as an
28-
internal sanity check guarding against a test like:
25+
other non-matched lines before and after, but not between $expected_lines,
26+
should you want to skip lines, you must include an elision comment, of the form
27+
(as a regex) `//\s*...\s*`. The lines will be skipped lazily, that is, if there
28+
are two identical lines in the output that match the line after the elision
29+
comment, the first one wil be matched.
30+
31+
Examples:
32+
33+
The following blocks will not match the one after it.
2934

3035
```
3136
bb0: {
@@ -35,8 +40,6 @@ bb0: {
3540
}
3641
```
3742

38-
that will inadvertantly pattern-matching against:
39-
4043
```
4144
bb0: {
4245
StorageLive(_1);
@@ -49,6 +52,18 @@ bb1: {
4952
}
5053
```
5154

55+
But this will match the one above,
56+
57+
```
58+
bb0: {
59+
StorageLive(_1);
60+
_1 = const true;
61+
...
62+
StorageDead(_1);
63+
...
64+
}
65+
```
66+
5267
Lines match ignoring whitespace, and the prefix "//" is removed.
5368

5469
It also currently strips trailing comments -- partly because the full file path

Diff for: src/test/mir-opt/box_expr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ impl Drop for S {
3030
// END RUST SOURCE
3131
// START rustc.node4.ElaborateDrops.before.mir
3232
// let mut _0: ();
33-
// let _1: std::boxed::Box<S>;
33+
// scope 1 {
34+
// let _1: std::boxed::Box<S>;
35+
// }
36+
// ...
3437
// let mut _2: std::boxed::Box<S>;
3538
// let mut _3: ();
3639
// let mut _4: std::boxed::Box<S>;

Diff for: src/test/mir-opt/copy_propagation.rs

+6
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@ fn main() { }
1818
// END RUST SOURCE
1919
// START rustc.node4.CopyPropagation.before.mir
2020
// bb0: {
21+
// ...
2122
// _2 = _1;
23+
// ...
2224
// _4 = _2;
2325
// _3 = _4;
26+
// ...
2427
// _5 = _3;
2528
// _0 = _5;
29+
// ...
2630
// return;
2731
// }
2832
// END rustc.node4.CopyPropagation.before.mir
2933
// START rustc.node4.CopyPropagation.after.mir
3034
// bb0: {
35+
// ...
3136
// _0 = _1;
37+
// ...
3238
// return;
3339
// }
3440
// END rustc.node4.CopyPropagation.after.mir

Diff for: src/test/mir-opt/deaggregator_test.rs

+6
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,25 @@ fn main() {}
2323
// END RUST SOURCE
2424
// START rustc.node13.Deaggregator.before.mir
2525
// bb0: {
26+
// ...
2627
// _2 = _1;
28+
// ...
2729
// _3 = _2;
2830
// _0 = Baz { x: _3, y: const 0f32, z: const false };
31+
// ...
2932
// return;
3033
// }
3134
// END rustc.node13.Deaggregator.before.mir
3235
// START rustc.node13.Deaggregator.after.mir
3336
// bb0: {
37+
// ...
3438
// _2 = _1;
39+
// ...
3540
// _3 = _2;
3641
// (_0.0: usize) = _3;
3742
// (_0.1: f32) = const 0f32;
3843
// (_0.2: bool) = const false;
44+
// ...
3945
// return;
4046
// }
4147
// END rustc.node13.Deaggregator.after.mir

Diff for: src/test/mir-opt/deaggregator_test_enum.rs

+8
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,26 @@ fn main() {
2828
// END RUST SOURCE
2929
// START rustc.node10.Deaggregator.before.mir
3030
// bb0: {
31+
// StorageLive(_2);
3132
// _2 = _1;
33+
// StorageLive(_3);
3234
// _3 = _2;
3335
// _0 = Baz::Foo { x: _3 };
36+
// StorageDead(_3);
37+
// StorageDead(_2);
3438
// return;
3539
// }
3640
// END rustc.node10.Deaggregator.before.mir
3741
// START rustc.node10.Deaggregator.after.mir
3842
// bb0: {
43+
// StorageLive(_2);
3944
// _2 = _1;
45+
// StorageLive(_3);
4046
// _3 = _2;
4147
// ((_0 as Foo).0: usize) = _3;
4248
// discriminant(_0) = 1;
49+
// StorageDead(_3);
50+
// StorageDead(_2);
4351
// return;
4452
// }
4553
// END rustc.node10.Deaggregator.after.mir

Diff for: src/test/mir-opt/deaggregator_test_enum_2.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,35 @@ fn main() {}
2828
// END RUST SOURCE
2929
// START rustc.node12.Deaggregator.before.mir
3030
// bb1: {
31+
// StorageLive(_6);
3132
// _6 = _4;
3233
// _0 = Foo::A(_6,);
34+
// StorageDead(_6);
3335
// goto -> bb3;
3436
// }
35-
//
3637
// bb2: {
38+
// StorageLive(_7);
3739
// _7 = _4;
3840
// _0 = Foo::B(_7,);
41+
// StorageDead(_7);
3942
// goto -> bb3;
4043
// }
4144
// END rustc.node12.Deaggregator.before.mir
4245
// START rustc.node12.Deaggregator.after.mir
4346
// bb1: {
47+
// StorageLive(_6);
4448
// _6 = _4;
4549
// ((_0 as A).0: i32) = _6;
4650
// discriminant(_0) = 0;
51+
// StorageDead(_6);
4752
// goto -> bb3;
4853
// }
49-
//
5054
// bb2: {
55+
// StorageLive(_7);
5156
// _7 = _4;
5257
// ((_0 as B).0: i32) = _7;
5358
// discriminant(_0) = 1;
59+
// StorageDead(_7);
5460
// goto -> bb3;
5561
// }
5662
// END rustc.node12.Deaggregator.after.mir

Diff for: src/test/mir-opt/deaggregator_test_multiple.rs

+10
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,35 @@ fn main() { }
2424
// END RUST SOURCE
2525
// START rustc.node10.Deaggregator.before.mir
2626
// bb0: {
27+
// ...
2728
// _2 = _1;
29+
// ...
2830
// _4 = _2;
2931
// _3 = Foo::A(_4,);
32+
// ...
3033
// _6 = _2;
3134
// _5 = Foo::A(_6,);
35+
// ...
3236
// _0 = [_3, _5];
37+
// ...
3338
// return;
3439
// }
3540
// END rustc.node10.Deaggregator.before.mir
3641
// START rustc.node10.Deaggregator.after.mir
3742
// bb0: {
43+
// ...
3844
// _2 = _1;
45+
// ...
3946
// _4 = _2;
4047
// ((_3 as A).0: i32) = _4;
4148
// discriminant(_3) = 0;
49+
// ...
4250
// _6 = _2;
4351
// ((_5 as A).0: i32) = _6;
4452
// discriminant(_5) = 0;
53+
// ...
4554
// _0 = [_3, _5];
55+
// ...
4656
// return;
4757
// }
4858
// END rustc.node10.Deaggregator.after.mir

Diff for: src/test/mir-opt/end_region_1.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ fn main() {
2121
// END RUST SOURCE
2222
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
2323
// let mut _0: ();
24+
// ...
2425
// let _1: i32;
26+
// ...
2527
// let _2: &'10_1rs i32;
26-
//
28+
// ...
2729
// bb0: {
2830
// StorageLive(_1);
2931
// _1 = const 3i32;

Diff for: src/test/mir-opt/end_region_2.rs

+6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ fn main() {
2626
// END RUST SOURCE
2727
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
2828
// let mut _0: ();
29+
// ...
2930
// let _2: bool;
31+
// ...
3032
// let _3: &'23_1rs bool;
33+
// ...
3134
// let _7: &'23_3rs bool;
35+
// ...
3236
// let mut _4: ();
3337
// let mut _5: bool;
38+
// ...
3439
// bb0: {
3540
// goto -> bb1;
3641
// }
@@ -52,6 +57,7 @@ fn main() {
5257
// return;
5358
// }
5459
// bb3: {
60+
// _4 = ();
5561
// StorageDead(_5);
5662
// StorageLive(_7);
5763
// _7 = &'23_3rs _2;

Diff for: src/test/mir-opt/end_region_3.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ fn main() {
2727
// END RUST SOURCE
2828
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
2929
// let mut _0: ();
30+
// ...
3031
// let mut _1: bool;
32+
// ...
3133
// let _3: &'26_1rs bool;
34+
// ...
3235
// let _7: &'26_3rs bool;
36+
// ...
3337
// let mut _2: ();
3438
// let mut _4: ();
3539
// let mut _5: bool;
36-
//
40+
// let mut _6: !;
3741
// bb0: {
3842
// StorageLive(_1);
3943
// goto -> bb1;

Diff for: src/test/mir-opt/end_region_4.rs

+5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ fn foo(i: i32) {
3131
// END RUST SOURCE
3232
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
3333
// let mut _0: ();
34+
// ...
3435
// let _1: D;
36+
// ...
3537
// let _2: i32;
38+
// ...
3639
// let _3: &'26_2rs i32;
40+
// ...
3741
// let _6: &'26_4rs i32;
42+
// ...
3843
// let mut _4: ();
3944
// let mut _5: i32;
4045
// bb0: {

Diff for: src/test/mir-opt/end_region_5.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2828
// END RUST SOURCE
2929
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
3030
// fn main() -> () {
31+
// ...
3132
// let mut _0: ();
33+
// ...
3234
// let _1: D;
35+
// ...
3336
// let mut _2: ();
3437
// let mut _3: [closure@NodeId(18) d:&'14s D];
3538
// let mut _4: &'14s D;

Diff for: src/test/mir-opt/end_region_6.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2929
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
3030
// fn main() -> () {
3131
// let mut _0: ();
32+
// ...
3233
// let _1: D;
34+
// ...
3335
// let mut _2: ();
3436
// let mut _3: [closure@NodeId(22) d:&'19s D];
3537
// let mut _4: &'19s D;
@@ -65,9 +67,10 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
6567
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir
6668
// fn main::{{closure}}(_1: [closure@NodeId(22) d:&'19s D]) -> i32 {
6769
// let mut _0: i32;
70+
// ...
6871
// let _2: &'15_0rs D;
72+
// ...
6973
// let mut _3: i32;
70-
//
7174
// bb0: {
7275
// StorageLive(_2);
7376
// _2 = &'15_0rs (*(_1.0: &'19s D));

Diff for: src/test/mir-opt/end_region_7.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
2929
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
3030
// fn main() -> () {
3131
// let mut _0: ();
32+
// ...
3233
// let _1: D;
34+
// ...
3335
// let mut _2: ();
3436
// let mut _3: [closure@NodeId(22) d:D];
3537
// let mut _4: D;
36-
//
3738
// bb0: {
3839
// StorageLive(_1);
3940
// _1 = D::{{constructor}}(const 0i32,);
@@ -74,9 +75,10 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
7475
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir
7576
// fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 {
7677
// let mut _0: i32;
78+
// ...
7779
// let _2: &'15_0rs D;
80+
// ...
7881
// let mut _3: i32;
79-
//
8082
// bb0: {
8183
// StorageLive(_2);
8284
// _2 = &'15_0rs (_1.0: D);

Diff for: src/test/mir-opt/end_region_8.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
3030
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
3131
// fn main() -> () {
3232
// let mut _0: ();
33+
// ...
3334
// let _1: D;
35+
// ...
3436
// let _2: &'21_1rs D;
37+
// ...
3538
// let mut _3: ();
3639
// let mut _4: [closure@NodeId(22) r:&'21_1rs D];
3740
// let mut _5: &'21_1rs D;

0 commit comments

Comments
 (0)