Auto merge of #45162 - chrisvittal:mir-testing, r=nikomatsakis

Modify MIR testing to require consecutive lines

MIR testing now requires that lines be consecutive. To achive this,
instead of collecting the expected mir as a string, it is now wrapped in
an `ExpectedLine` enum, that is either `Elision` or `Text(T)` where `T:
AsRef<str>`. `Text` lines must be matched in order, unless separated by
`Elision` lines. Elision occurs lazily, that is, an Elision will skip
as few lines as possible.

To add a new elision marker. Put a comment containing only "..." and
whitespace in any MIR testing block. Like so:

```
// fn write_42(_1: *mut i32) -> bool {
//     ...
//     bb0: {
//         Validate(Acquire, [_1: *mut i32]);
//         Validate(Release, [_1: *mut i32]);
//         ...
//         return;
//     }
// }
```

Right now, all input before the line right after `// START` is elided,
and all input after the line right before `// END` is also not tested.

Many tests need to be updated. That will follow in the next commit.

cc #45153
r? @nikomatsakis
This commit is contained in:
bors 2017-10-14 11:22:46 +00:00
commit af7de7b677
26 changed files with 400 additions and 107 deletions

View File

@ -7,13 +7,13 @@ The test format is:
// END RUST SOURCE // END RUST SOURCE
// START $file_name_of_some_mir_dump_0 // START $file_name_of_some_mir_dump_0
// $expected_line_0 // $expected_line_0
// ... // (lines or elision)
// $expected_line_N // $expected_line_N
// END $file_name_of_some_mir_dump_0 // END $file_name_of_some_mir_dump_0
// ... // (lines or elision)
// START $file_name_of_some_mir_dump_N // START $file_name_of_some_mir_dump_N
// $expected_line_0 // $expected_line_0
// ... // (lines or elision)
// $expected_line_N // $expected_line_N
// END $file_name_of_some_mir_dump_N // END $file_name_of_some_mir_dump_N
``` ```
@ -22,10 +22,15 @@ All the test information is in comments so the test is runnable.
For each $file_name, compiletest expects [$expected_line_0, ..., For each $file_name, compiletest expects [$expected_line_0, ...,
$expected_line_N] to appear in the dumped MIR in order. Currently it allows $expected_line_N] to appear in the dumped MIR in order. Currently it allows
other non-matched lines before, after and in-between. Note that this includes other non-matched lines before and after, but not between $expected_lines,
lines that end basic blocks or begin new ones; it is good practice should you want to skip lines, you must include an elision comment, of the form
in your tests to include the terminator for each of your basic blocks as an (as a regex) `//\s*...\s*`. The lines will be skipped lazily, that is, if there
internal sanity check guarding against a test like: are two identical lines in the output that match the line after the elision
comment, the first one wil be matched.
Examples:
The following blocks will not match the one after it.
``` ```
bb0: { bb0: {
@ -35,8 +40,6 @@ bb0: {
} }
``` ```
that will inadvertantly pattern-matching against:
``` ```
bb0: { bb0: {
StorageLive(_1); StorageLive(_1);
@ -49,6 +52,18 @@ bb1: {
} }
``` ```
But this will match the one above,
```
bb0: {
StorageLive(_1);
_1 = const true;
...
StorageDead(_1);
...
}
```
Lines match ignoring whitespace, and the prefix "//" is removed. Lines match ignoring whitespace, and the prefix "//" is removed.
It also currently strips trailing comments -- partly because the full file path It also currently strips trailing comments -- partly because the full file path

View File

@ -30,7 +30,10 @@ impl Drop for S {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.ElaborateDrops.before.mir // START rustc.node4.ElaborateDrops.before.mir
// let mut _0: (); // let mut _0: ();
// let _1: std::boxed::Box<S>; // scope 1 {
// let _1: std::boxed::Box<S>;
// }
// ...
// let mut _2: std::boxed::Box<S>; // let mut _2: std::boxed::Box<S>;
// let mut _3: (); // let mut _3: ();
// let mut _4: std::boxed::Box<S>; // let mut _4: std::boxed::Box<S>;

View File

@ -18,17 +18,23 @@ fn main() { }
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.CopyPropagation.before.mir // START rustc.node4.CopyPropagation.before.mir
// bb0: { // bb0: {
// ...
// _2 = _1; // _2 = _1;
// ...
// _4 = _2; // _4 = _2;
// _3 = _4; // _3 = _4;
// ...
// _5 = _3; // _5 = _3;
// _0 = _5; // _0 = _5;
// ...
// return; // return;
// } // }
// END rustc.node4.CopyPropagation.before.mir // END rustc.node4.CopyPropagation.before.mir
// START rustc.node4.CopyPropagation.after.mir // START rustc.node4.CopyPropagation.after.mir
// bb0: { // bb0: {
// ...
// _0 = _1; // _0 = _1;
// ...
// return; // return;
// } // }
// END rustc.node4.CopyPropagation.after.mir // END rustc.node4.CopyPropagation.after.mir

View File

@ -23,19 +23,25 @@ fn main() {}
// END RUST SOURCE // END RUST SOURCE
// START rustc.node13.Deaggregator.before.mir // START rustc.node13.Deaggregator.before.mir
// bb0: { // bb0: {
// ...
// _2 = _1; // _2 = _1;
// ...
// _3 = _2; // _3 = _2;
// _0 = Baz { x: _3, y: const 0f32, z: const false }; // _0 = Baz { x: _3, y: const 0f32, z: const false };
// ...
// return; // return;
// } // }
// END rustc.node13.Deaggregator.before.mir // END rustc.node13.Deaggregator.before.mir
// START rustc.node13.Deaggregator.after.mir // START rustc.node13.Deaggregator.after.mir
// bb0: { // bb0: {
// ...
// _2 = _1; // _2 = _1;
// ...
// _3 = _2; // _3 = _2;
// (_0.0: usize) = _3; // (_0.0: usize) = _3;
// (_0.1: f32) = const 0f32; // (_0.1: f32) = const 0f32;
// (_0.2: bool) = const false; // (_0.2: bool) = const false;
// ...
// return; // return;
// } // }
// END rustc.node13.Deaggregator.after.mir // END rustc.node13.Deaggregator.after.mir

View File

@ -28,18 +28,26 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node10.Deaggregator.before.mir // START rustc.node10.Deaggregator.before.mir
// bb0: { // bb0: {
// StorageLive(_2);
// _2 = _1; // _2 = _1;
// StorageLive(_3);
// _3 = _2; // _3 = _2;
// _0 = Baz::Foo { x: _3 }; // _0 = Baz::Foo { x: _3 };
// StorageDead(_3);
// StorageDead(_2);
// return; // return;
// } // }
// END rustc.node10.Deaggregator.before.mir // END rustc.node10.Deaggregator.before.mir
// START rustc.node10.Deaggregator.after.mir // START rustc.node10.Deaggregator.after.mir
// bb0: { // bb0: {
// StorageLive(_2);
// _2 = _1; // _2 = _1;
// StorageLive(_3);
// _3 = _2; // _3 = _2;
// ((_0 as Foo).0: usize) = _3; // ((_0 as Foo).0: usize) = _3;
// discriminant(_0) = 1; // discriminant(_0) = 1;
// StorageDead(_3);
// StorageDead(_2);
// return; // return;
// } // }
// END rustc.node10.Deaggregator.after.mir // END rustc.node10.Deaggregator.after.mir

View File

@ -28,29 +28,35 @@ fn main() {}
// END RUST SOURCE // END RUST SOURCE
// START rustc.node12.Deaggregator.before.mir // START rustc.node12.Deaggregator.before.mir
// bb1: { // bb1: {
// StorageLive(_6);
// _6 = _4; // _6 = _4;
// _0 = Foo::A(_6,); // _0 = Foo::A(_6,);
// StorageDead(_6);
// goto -> bb3; // goto -> bb3;
// } // }
//
// bb2: { // bb2: {
// StorageLive(_7);
// _7 = _4; // _7 = _4;
// _0 = Foo::B(_7,); // _0 = Foo::B(_7,);
// StorageDead(_7);
// goto -> bb3; // goto -> bb3;
// } // }
// END rustc.node12.Deaggregator.before.mir // END rustc.node12.Deaggregator.before.mir
// START rustc.node12.Deaggregator.after.mir // START rustc.node12.Deaggregator.after.mir
// bb1: { // bb1: {
// StorageLive(_6);
// _6 = _4; // _6 = _4;
// ((_0 as A).0: i32) = _6; // ((_0 as A).0: i32) = _6;
// discriminant(_0) = 0; // discriminant(_0) = 0;
// StorageDead(_6);
// goto -> bb3; // goto -> bb3;
// } // }
//
// bb2: { // bb2: {
// StorageLive(_7);
// _7 = _4; // _7 = _4;
// ((_0 as B).0: i32) = _7; // ((_0 as B).0: i32) = _7;
// discriminant(_0) = 1; // discriminant(_0) = 1;
// StorageDead(_7);
// goto -> bb3; // goto -> bb3;
// } // }
// END rustc.node12.Deaggregator.after.mir // END rustc.node12.Deaggregator.after.mir

View File

@ -24,25 +24,35 @@ fn main() { }
// END RUST SOURCE // END RUST SOURCE
// START rustc.node10.Deaggregator.before.mir // START rustc.node10.Deaggregator.before.mir
// bb0: { // bb0: {
// ...
// _2 = _1; // _2 = _1;
// ...
// _4 = _2; // _4 = _2;
// _3 = Foo::A(_4,); // _3 = Foo::A(_4,);
// ...
// _6 = _2; // _6 = _2;
// _5 = Foo::A(_6,); // _5 = Foo::A(_6,);
// ...
// _0 = [_3, _5]; // _0 = [_3, _5];
// ...
// return; // return;
// } // }
// END rustc.node10.Deaggregator.before.mir // END rustc.node10.Deaggregator.before.mir
// START rustc.node10.Deaggregator.after.mir // START rustc.node10.Deaggregator.after.mir
// bb0: { // bb0: {
// ...
// _2 = _1; // _2 = _1;
// ...
// _4 = _2; // _4 = _2;
// ((_3 as A).0: i32) = _4; // ((_3 as A).0: i32) = _4;
// discriminant(_3) = 0; // discriminant(_3) = 0;
// ...
// _6 = _2; // _6 = _2;
// ((_5 as A).0: i32) = _6; // ((_5 as A).0: i32) = _6;
// discriminant(_5) = 0; // discriminant(_5) = 0;
// ...
// _0 = [_3, _5]; // _0 = [_3, _5];
// ...
// return; // return;
// } // }
// END rustc.node10.Deaggregator.after.mir // END rustc.node10.Deaggregator.after.mir

View File

@ -21,9 +21,11 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// let mut _0: (); // let mut _0: ();
// ...
// let _1: i32; // let _1: i32;
// ...
// let _2: &'10_1rs i32; // let _2: &'10_1rs i32;
// // ...
// bb0: { // bb0: {
// StorageLive(_1); // StorageLive(_1);
// _1 = const 3i32; // _1 = const 3i32;

View File

@ -26,11 +26,16 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// let mut _0: (); // let mut _0: ();
// ...
// let _2: bool; // let _2: bool;
// ...
// let _3: &'23_1rs bool; // let _3: &'23_1rs bool;
// ...
// let _7: &'23_3rs bool; // let _7: &'23_3rs bool;
// ...
// let mut _4: (); // let mut _4: ();
// let mut _5: bool; // let mut _5: bool;
// ...
// bb0: { // bb0: {
// goto -> bb1; // goto -> bb1;
// } // }
@ -52,6 +57,7 @@ fn main() {
// return; // return;
// } // }
// bb3: { // bb3: {
// _4 = ();
// StorageDead(_5); // StorageDead(_5);
// StorageLive(_7); // StorageLive(_7);
// _7 = &'23_3rs _2; // _7 = &'23_3rs _2;

View File

@ -27,13 +27,17 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// let mut _0: (); // let mut _0: ();
// ...
// let mut _1: bool; // let mut _1: bool;
// ...
// let _3: &'26_1rs bool; // let _3: &'26_1rs bool;
// ...
// let _7: &'26_3rs bool; // let _7: &'26_3rs bool;
// ...
// let mut _2: (); // let mut _2: ();
// let mut _4: (); // let mut _4: ();
// let mut _5: bool; // let mut _5: bool;
// // let mut _6: !;
// bb0: { // bb0: {
// StorageLive(_1); // StorageLive(_1);
// goto -> bb1; // goto -> bb1;

View File

@ -31,10 +31,15 @@ fn foo(i: i32) {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// let mut _0: (); // let mut _0: ();
// ...
// let _1: D; // let _1: D;
// ...
// let _2: i32; // let _2: i32;
// ...
// let _3: &'26_2rs i32; // let _3: &'26_2rs i32;
// ...
// let _6: &'26_4rs i32; // let _6: &'26_4rs i32;
// ...
// let mut _4: (); // let mut _4: ();
// let mut _5: i32; // let mut _5: i32;
// bb0: { // bb0: {

View File

@ -28,8 +28,11 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () { // fn main() -> () {
// ...
// let mut _0: (); // let mut _0: ();
// ...
// let _1: D; // let _1: D;
// ...
// let mut _2: (); // let mut _2: ();
// let mut _3: [closure@NodeId(18) d:&'14s D]; // let mut _3: [closure@NodeId(18) d:&'14s D];
// let mut _4: &'14s D; // let mut _4: &'14s D;

View File

@ -29,7 +29,9 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () { // fn main() -> () {
// let mut _0: (); // let mut _0: ();
// ...
// let _1: D; // let _1: D;
// ...
// let mut _2: (); // let mut _2: ();
// let mut _3: [closure@NodeId(22) d:&'19s D]; // let mut _3: [closure@NodeId(22) d:&'19s D];
// let mut _4: &'19s D; // let mut _4: &'19s D;
@ -65,9 +67,10 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir // START rustc.node22.SimplifyCfg-qualify-consts.after.mir
// fn main::{{closure}}(_1: [closure@NodeId(22) d:&'19s D]) -> i32 { // fn main::{{closure}}(_1: [closure@NodeId(22) d:&'19s D]) -> i32 {
// let mut _0: i32; // let mut _0: i32;
// ...
// let _2: &'15_0rs D; // let _2: &'15_0rs D;
// ...
// let mut _3: i32; // let mut _3: i32;
//
// bb0: { // bb0: {
// StorageLive(_2); // StorageLive(_2);
// _2 = &'15_0rs (*(_1.0: &'19s D)); // _2 = &'15_0rs (*(_1.0: &'19s D));

View File

@ -29,11 +29,12 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () { // fn main() -> () {
// let mut _0: (); // let mut _0: ();
// ...
// let _1: D; // let _1: D;
// ...
// let mut _2: (); // let mut _2: ();
// let mut _3: [closure@NodeId(22) d:D]; // let mut _3: [closure@NodeId(22) d:D];
// let mut _4: D; // let mut _4: D;
//
// bb0: { // bb0: {
// StorageLive(_1); // StorageLive(_1);
// _1 = D::{{constructor}}(const 0i32,); // _1 = D::{{constructor}}(const 0i32,);
@ -74,9 +75,10 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// START rustc.node22.SimplifyCfg-qualify-consts.after.mir // START rustc.node22.SimplifyCfg-qualify-consts.after.mir
// fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 { // fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 {
// let mut _0: i32; // let mut _0: i32;
// ...
// let _2: &'15_0rs D; // let _2: &'15_0rs D;
// ...
// let mut _3: i32; // let mut _3: i32;
//
// bb0: { // bb0: {
// StorageLive(_2); // StorageLive(_2);
// _2 = &'15_0rs (_1.0: D); // _2 = &'15_0rs (_1.0: D);

View File

@ -30,8 +30,11 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () { // fn main() -> () {
// let mut _0: (); // let mut _0: ();
// ...
// let _1: D; // let _1: D;
// ...
// let _2: &'21_1rs D; // let _2: &'21_1rs D;
// ...
// let mut _3: (); // let mut _3: ();
// let mut _4: [closure@NodeId(22) r:&'21_1rs D]; // let mut _4: [closure@NodeId(22) r:&'21_1rs D];
// let mut _5: &'21_1rs D; // let mut _5: &'21_1rs D;

View File

@ -40,15 +40,18 @@ fn main() {
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
// fn main() -> () { // fn main() -> () {
// let mut _0: (); // let mut _0: ();
// ...
// let mut _1: bool; // let mut _1: bool;
// ...
// let _2: i32; // let _2: i32;
// ...
// let mut _4: &'33_0rs i32; // let mut _4: &'33_0rs i32;
// ...
// let mut _3: (); // let mut _3: ();
// let mut _5: !; // let mut _5: !;
// let mut _6: (); // let mut _6: ();
// let mut _7: bool; // let mut _7: bool;
// let mut _8: !; // let mut _8: !;
//
// bb0: { // bb0: {
// StorageLive(_1); // StorageLive(_1);
// _1 = const false; // _1 = const false;
@ -63,7 +66,6 @@ fn main() {
// _7 = _1; // _7 = _1;
// switchInt(_7) -> [0u8: bb3, otherwise: bb2]; // switchInt(_7) -> [0u8: bb3, otherwise: bb2];
// } // }
//
// bb2: { // bb2: {
// _0 = (); // _0 = ();
// StorageDead(_7); // StorageDead(_7);
@ -73,7 +75,6 @@ fn main() {
// StorageDead(_1); // StorageDead(_1);
// return; // return;
// } // }
//
// bb3: { // bb3: {
// _4 = &'33_0rs _2; // _4 = &'33_0rs _2;
// _6 = (); // _6 = ();

View File

@ -45,6 +45,7 @@ fn query() -> bool { true }
// scope 1 { // scope 1 {
// let _2: S<'35_0rs>; // let _2: S<'35_0rs>;
// } // }
// ...
// let mut _1: (); // let mut _1: ();
// let mut _3: std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>; // let mut _3: std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>;
// let mut _4: std::option::Option<&'35_0rs S<'35_0rs>>; // let mut _4: std::option::Option<&'35_0rs S<'35_0rs>>;

View File

@ -35,22 +35,26 @@ impl S {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.ElaborateDrops.after.mir // START rustc.node4.ElaborateDrops.after.mir
// let mut _0: (); // let mut _0: ();
// let _1: (); // scope 1 {
// let _1: ();
// }
// ...
// let mut _2: S; // let mut _2: S;
// let mut _3: S; // let mut _3: S;
// let mut _4: S; // let mut _4: S;
// let mut _5: bool; // let mut _5: bool;
//
// bb0: { // bb0: {
// END rustc.node4.ElaborateDrops.after.mir // END rustc.node4.ElaborateDrops.after.mir
// START rustc.node13.ElaborateDrops.after.mir // START rustc.node13.ElaborateDrops.after.mir
// let mut _0: (); // let mut _0: ();
// ...
// let _1: S; // let _1: S;
// ...
// let mut _2: S; // let mut _2: S;
// ...
// let mut _3: (); // let mut _3: ();
// let mut _4: S; // let mut _4: S;
// let mut _5: S; // let mut _5: S;
// let mut _6: bool; // let mut _6: bool;
//
// bb0: { // bb0: {
// END rustc.node13.ElaborateDrops.after.mir // END rustc.node13.ElaborateDrops.after.mir

View File

@ -45,56 +45,156 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.mir_map.0.mir // START rustc.node4.mir_map.0.mir
// let mut _0: &'static Foo;
// let mut _1: &'static Foo;
// let mut _2: Foo;
// let mut _3: &'static [(u32, u32)];
// let mut _4: &'static [(u32, u32); 42];
// let mut _5: &'static [(u32, u32); 42];
// let mut _6: [(u32, u32); 42];
// let mut _7: (u32, u32);
// let mut _8: (u32, u32);
// let mut _9: (u32, u32);
// let mut _10: (u32, u32);
// let mut _11: (u32, u32);
// let mut _12: (u32, u32);
// let mut _13: (u32, u32);
// let mut _14: (u32, u32);
// let mut _15: (u32, u32);
// let mut _16: (u32, u32);
// let mut _17: (u32, u32);
// let mut _18: (u32, u32);
// let mut _19: (u32, u32);
// let mut _20: (u32, u32);
// let mut _21: (u32, u32);
// let mut _22: (u32, u32);
// let mut _23: (u32, u32);
// let mut _24: (u32, u32);
// let mut _25: (u32, u32);
// let mut _26: (u32, u32);
// let mut _27: (u32, u32);
// let mut _28: (u32, u32);
// let mut _29: (u32, u32);
// let mut _30: (u32, u32);
// let mut _31: (u32, u32);
// let mut _32: (u32, u32);
// let mut _33: (u32, u32);
// let mut _34: (u32, u32);
// let mut _35: (u32, u32);
// let mut _36: (u32, u32);
// let mut _37: (u32, u32);
// let mut _38: (u32, u32);
// let mut _39: (u32, u32);
// let mut _40: (u32, u32);
// let mut _41: (u32, u32);
// let mut _42: (u32, u32);
// let mut _43: (u32, u32);
// let mut _44: (u32, u32);
// let mut _45: (u32, u32);
// let mut _46: (u32, u32);
// let mut _47: (u32, u32);
// let mut _48: (u32, u32);
// bb0: { // bb0: {
// _7 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:29:9: 29:15 // StorageLive(_1);
// _8 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:29:17: 29:23 // StorageLive(_2);
// _9 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:29:25: 29:31 // StorageLive(_3);
// _10 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:30:9: 30:15 // StorageLive(_4);
// _11 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:30:17: 30:23 // StorageLive(_5);
// _12 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:30:25: 30:31 // StorageLive(_6);
// _13 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:31:9: 31:15 // StorageLive(_7);
// _14 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:31:17: 31:23 // _7 = (const 0u32, const 1u32);
// _15 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:31:25: 31:31 // StorageLive(_8);
// _16 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:32:9: 32:15 // _8 = (const 0u32, const 2u32);
// _17 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:32:17: 32:23 // StorageLive(_9);
// _18 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:32:25: 32:31 // _9 = (const 0u32, const 3u32);
// _19 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:33:9: 33:15 // StorageLive(_10);
// _20 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:33:17: 33:23 // _10 = (const 0u32, const 1u32);
// _21 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:33:25: 33:31 // StorageLive(_11);
// _22 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:34:9: 34:15 // _11 = (const 0u32, const 2u32);
// _23 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:34:17: 34:23 // StorageLive(_12);
// _24 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:34:25: 34:31 // _12 = (const 0u32, const 3u32);
// _25 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:35:9: 35:15 // StorageLive(_13);
// _26 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:35:17: 35:23 // _13 = (const 0u32, const 1u32);
// _27 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:35:25: 35:31 // StorageLive(_14);
// _28 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:36:9: 36:15 // _14 = (const 0u32, const 2u32);
// _29 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:36:17: 36:23 // StorageLive(_15);
// _30 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:36:25: 36:31 // _15 = (const 0u32, const 3u32);
// _31 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:37:9: 37:15 // StorageLive(_16);
// _32 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:37:17: 37:23 // _16 = (const 0u32, const 1u32);
// _33 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:37:25: 37:31 // StorageLive(_17);
// _34 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:38:9: 38:15 // _17 = (const 0u32, const 2u32);
// _35 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:38:17: 38:23 // StorageLive(_18);
// _36 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:38:25: 38:31 // _18 = (const 0u32, const 3u32);
// _37 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:39:9: 39:15 // StorageLive(_19);
// _38 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:39:17: 39:23 // _19 = (const 0u32, const 1u32);
// _39 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:39:25: 39:31 // StorageLive(_20);
// _40 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:40:9: 40:15 // _20 = (const 0u32, const 2u32);
// _41 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:40:17: 40:23 // StorageLive(_21);
// _42 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:40:25: 40:31 // _21 = (const 0u32, const 3u32);
// _43 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:41:9: 41:15 // StorageLive(_22);
// _44 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:41:17: 41:23 // _22 = (const 0u32, const 1u32);
// _45 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:41:25: 41:31 // StorageLive(_23);
// _46 = (const 0u32, const 1u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:42:9: 42:15 // _23 = (const 0u32, const 2u32);
// _47 = (const 0u32, const 2u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:42:17: 42:23 // StorageLive(_24);
// _48 = (const 0u32, const 3u32); // scope 0 at src/test/mir-opt/basic_assignment.rs:42:25: 42:31 // _24 = (const 0u32, const 3u32);
// _6 = [_7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48]; // scope 0 at src/test/mir-opt/basic_assignment.rs:28:12: 43:6 // StorageLive(_25);
// _5 = &_6; // scope 0 at src/test/mir-opt/basic_assignment.rs:28:11: 43:6 // _25 = (const 0u32, const 1u32);
// _4 = &(*_5); // scope 0 at src/test/mir-opt/basic_assignment.rs:28:11: 43:6 // StorageLive(_26);
// _3 = _4 as &'static [(u32, u32)] (Unsize); // scope 0 at src/test/mir-opt/basic_assignment.rs:28:11: 43:6 // _26 = (const 0u32, const 2u32);
// _2 = Foo { tup: const "hi", data: _3 }; // scope 0 at src/test/mir-opt/basic_assignment.rs:26:29: 44:2 // StorageLive(_27);
// _1 = &_2; // scope 0 at src/test/mir-opt/basic_assignment.rs:26:28: 44:2 // _27 = (const 0u32, const 3u32);
// _0 = &(*_1); // scope 0 at src/test/mir-opt/basic_assignment.rs:26:28: 44:2 // StorageLive(_28);
// return; // scope 0 at src/test/mir-opt/basic_assignment.rs:26:1: 44:3 // _28 = (const 0u32, const 1u32);
// StorageLive(_29);
// _29 = (const 0u32, const 2u32);
// StorageLive(_30);
// _30 = (const 0u32, const 3u32);
// StorageLive(_31);
// _31 = (const 0u32, const 1u32);
// StorageLive(_32);
// _32 = (const 0u32, const 2u32);
// StorageLive(_33);
// _33 = (const 0u32, const 3u32);
// StorageLive(_34);
// _34 = (const 0u32, const 1u32);
// StorageLive(_35);
// _35 = (const 0u32, const 2u32);
// StorageLive(_36);
// _36 = (const 0u32, const 3u32);
// StorageLive(_37);
// _37 = (const 0u32, const 1u32);
// StorageLive(_38);
// _38 = (const 0u32, const 2u32);
// StorageLive(_39);
// _39 = (const 0u32, const 3u32);
// StorageLive(_40);
// _40 = (const 0u32, const 1u32);
// StorageLive(_41);
// _41 = (const 0u32, const 2u32);
// StorageLive(_42);
// _42 = (const 0u32, const 3u32);
// StorageLive(_43);
// _43 = (const 0u32, const 1u32);
// StorageLive(_44);
// _44 = (const 0u32, const 2u32);
// StorageLive(_45);
// _45 = (const 0u32, const 3u32);
// StorageLive(_46);
// _46 = (const 0u32, const 1u32);
// StorageLive(_47);
// _47 = (const 0u32, const 2u32);
// StorageLive(_48);
// _48 = (const 0u32, const 3u32);
// _6 = [_7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48];
// _5 = &_6;
// _4 = &(*_5);
// _3 = _4 as &'static [(u32, u32)] (Unsize);
// _2 = Foo { tup: const "hi", data: _3 };
// _1 = &_2;
// _0 = &(*_1);
// StorageDead(_1);
// StorageDead(_5);
// return;
// } // }
//}
// END rustc.node4.mir_map.0.mir // END rustc.node4.mir_map.0.mir

View File

@ -38,5 +38,6 @@ fn main() {
// _0 = (); // _0 = ();
// StorageDead(_6); // StorageDead(_6);
// StorageDead(_1); // StorageDead(_1);
// return;
// } // }
// END rustc.node4.TypeckMir.before.mir // END rustc.node4.TypeckMir.before.mir

View File

@ -31,12 +31,15 @@ fn main() {
// START rustc.node12.EraseRegions.after.mir // START rustc.node12.EraseRegions.after.mir
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[8cd8]::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[8cd8]::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[8cd8]::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[8cd8]::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]);
// ...
// return; // return;
// } // }
// END rustc.node12.EraseRegions.after.mir // END rustc.node12.EraseRegions.after.mir
// START rustc.node23.EraseRegions.after.mir // START rustc.node23.EraseRegions.after.mir
// fn main() -> () { // fn main() -> () {
// ...
// bb0: { // bb0: {
// ...
// Validate(Suspend(ReScope(Node(ItemLocalId(10)))), [_1: i32]); // Validate(Suspend(ReScope(Node(ItemLocalId(10)))), [_1: i32]);
// _6 = &ReErased mut _1; // _6 = &ReErased mut _1;
// Validate(Acquire, [(*_6): i32/ReScope(Node(ItemLocalId(10)))]); // Validate(Acquire, [(*_6): i32/ReScope(Node(ItemLocalId(10)))]);
@ -50,12 +53,14 @@ fn main() {
// bb1: { // bb1: {
// Validate(Acquire, [_2: ()]); // Validate(Acquire, [_2: ()]);
// EndRegion(ReScope(Node(ItemLocalId(10)))); // EndRegion(ReScope(Node(ItemLocalId(10))));
// ...
// return; // return;
// } // }
// } // }
// END rustc.node23.EraseRegions.after.mir // END rustc.node23.EraseRegions.after.mir
// START rustc.node50.EraseRegions.after.mir // START rustc.node50.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3); // StorageLive(_3);

View File

@ -18,10 +18,18 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.EraseRegions.after.mir // START rustc.node4.EraseRegions.after.mir
// fn main() -> () { // fn main() -> () {
// ...
// bb1: { // bb1: {
// Validate(Acquire, [_2: std::boxed::Box<[i32; 3]>]);
// Validate(Release, [_2: std::boxed::Box<[i32; 3]>]); // Validate(Release, [_2: std::boxed::Box<[i32; 3]>]);
// _1 = _2 as std::boxed::Box<[i32]> (Unsize); // _1 = _2 as std::boxed::Box<[i32]> (Unsize);
// Validate(Acquire, [_1: std::boxed::Box<[i32]>]); // Validate(Acquire, [_1: std::boxed::Box<[i32]>]);
// StorageDead(_2);
// StorageDead(_3);
// _0 = ();
// Validate(Release, [_1: std::boxed::Box<[i32]>]);
// drop(_1) -> bb2;
// } // }
// ...
// } // }
// END rustc.node4.EraseRegions.after.mir // END rustc.node4.EraseRegions.after.mir

View File

@ -30,8 +30,17 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node16.EraseRegions.after.mir // START rustc.node16.EraseRegions.after.mir
// fn main() -> () { // fn main() -> () {
// ...
// let mut _5: &ReErased i32; // let mut _5: &ReErased i32;
// bb0: { // bb0: {
// StorageLive(_1);
// _1 = Test { x: const 0i32 };
// StorageLive(_2);
// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 }))), [_1: Test]);
// _2 = &ReErased _1;
// Validate(Acquire, [(*_2): Test/ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 })) (imm)]);
// StorageLive(_4);
// StorageLive(_5);
// Validate(Suspend(ReScope(Node(ItemLocalId(17)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 })) (imm)]); // Validate(Suspend(ReScope(Node(ItemLocalId(17)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 })) (imm)]);
// _5 = &ReErased ((*_2).0: i32); // _5 = &ReErased ((*_2).0: i32);
// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(17))) (imm)]); // Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(17))) (imm)]);
@ -42,8 +51,14 @@ fn main() {
// _3 = const foo(_4) -> bb1; // _3 = const foo(_4) -> bb1;
// } // }
// bb1: { // bb1: {
// Validate(Acquire, [_3: ()]);
// EndRegion(ReScope(Node(ItemLocalId(17)))); // EndRegion(ReScope(Node(ItemLocalId(17))));
// StorageDead(_4);
// StorageDead(_5);
// _0 = ();
// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 }))); // EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 })));
// StorageDead(_2);
// StorageDead(_1);
// return; // return;
// } // }
// } // }

View File

@ -38,15 +38,18 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node4.EraseRegions.after.mir // START rustc.node4.EraseRegions.after.mir
// fn write_42(_1: *mut i32) -> bool { // fn write_42(_1: *mut i32) -> bool {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: *mut i32]); // Validate(Acquire, [_1: *mut i32]);
// Validate(Release, [_1: *mut i32]); // Validate(Release, [_1: *mut i32]);
// ...
// return; // return;
// } // }
// } // }
// END rustc.node4.EraseRegions.after.mir // END rustc.node4.EraseRegions.after.mir
// START rustc.node22.EraseRegions.after.mir // START rustc.node22.EraseRegions.after.mir
// fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () { // fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); // Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[8cd8]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]);
@ -60,24 +63,30 @@ fn main() {
// END rustc.node22.EraseRegions.after.mir // END rustc.node22.EraseRegions.after.mir
// START rustc.node31.EraseRegions.after.mir // START rustc.node31.EraseRegions.after.mir
// fn test(_1: &ReErased mut i32) -> () { // fn test(_1: &ReErased mut i32) -> () {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[8cd8]::test[0] }, BrAnon(0)) mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[8cd8]::test[0] }, BrAnon(0)) mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[8cd8]::test[0] }, BrAnon(0)) mut i32]); // Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[8cd8]::test[0] }, BrAnon(0)) mut i32]);
// ...
// _3 = const write_42(_4) -> bb1; // _3 = const write_42(_4) -> bb1;
// } // }
// bb1: { // bb1: {
// Validate(Acquire, [_3: bool]); // Validate(Acquire, [_3: bool]);
// Validate(Release, [_3: bool]); // Validate(Release, [_3: bool]);
// ...
// } // }
// } // }
// END rustc.node31.EraseRegions.after.mir // END rustc.node31.EraseRegions.after.mir
// START rustc.node60.EraseRegions.after.mir // START rustc.node60.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3); // StorageLive(_3);
// ...
// _0 = const write_42(_4) -> bb1; // _0 = const write_42(_4) -> bb1;
// } // }
// ...
// } // }
// END rustc.node60.EraseRegions.after.mir // END rustc.node60.EraseRegions.after.mir

View File

@ -35,15 +35,19 @@ fn main() {
// END RUST SOURCE // END RUST SOURCE
// START rustc.node17.EraseRegions.after.mir // START rustc.node17.EraseRegions.after.mir
// fn test(_1: &ReErased mut i32) -> () { // fn test(_1: &ReErased mut i32) -> () {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_5[8cd8]::test[0] }, BrAnon(0)) mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_5[8cd8]::test[0] }, BrAnon(0)) mut i32]);
// ...
// Validate(Release, [_3: bool, _4: *mut i32]); // Validate(Release, [_3: bool, _4: *mut i32]);
// _3 = const write_42(_4) -> bb1; // _3 = const write_42(_4) -> bb1;
// } // }
// ...
// } // }
// END rustc.node17.EraseRegions.after.mir // END rustc.node17.EraseRegions.after.mir
// START rustc.node46.EraseRegions.after.mir // START rustc.node46.EraseRegions.after.mir
// fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool {
// ...
// bb0: { // bb0: {
// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[8cd8]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]);
// StorageLive(_3); // StorageLive(_3);
@ -59,5 +63,6 @@ fn main() {
// Validate(Release, [_0: bool, _4: *mut i32]); // Validate(Release, [_0: bool, _4: *mut i32]);
// _0 = const write_42(_4) -> bb1; // _0 = const write_42(_4) -> bb1;
// } // }
// ...
// } // }
// END rustc.node46.EraseRegions.after.mir // END rustc.node46.EraseRegions.after.mir

View File

@ -25,6 +25,7 @@ use std::collections::HashSet;
use std::env; use std::env;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs::{self, File, create_dir_all}; use std::fs::{self, File, create_dir_all};
use std::fmt;
use std::io::prelude::*; use std::io::prelude::*;
use std::io::{self, BufReader}; use std::io::{self, BufReader};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -2228,7 +2229,7 @@ actual:\n\
let (_, tests_text) = test_file_contents.split_at(idx + "// END_RUST SOURCE".len()); let (_, tests_text) = test_file_contents.split_at(idx + "// END_RUST SOURCE".len());
let tests_text_str = String::from(tests_text); let tests_text_str = String::from(tests_text);
let mut curr_test : Option<&str> = None; let mut curr_test : Option<&str> = None;
let mut curr_test_contents = Vec::new(); let mut curr_test_contents = vec![ExpectedLine::Elision];
for l in tests_text_str.lines() { for l in tests_text_str.lines() {
debug!("line: {:?}", l); debug!("line: {:?}", l);
if l.starts_with("// START ") { if l.starts_with("// START ") {
@ -2242,11 +2243,14 @@ actual:\n\
self.compare_mir_test_output(curr_test.unwrap(), &curr_test_contents); self.compare_mir_test_output(curr_test.unwrap(), &curr_test_contents);
curr_test = None; curr_test = None;
curr_test_contents.clear(); curr_test_contents.clear();
curr_test_contents.push(ExpectedLine::Elision);
} else if l.is_empty() { } else if l.is_empty() {
// ignore // ignore
} else if l.starts_with("//") && l.split_at("//".len()).1.trim() == "..." {
curr_test_contents.push(ExpectedLine::Elision)
} else if l.starts_with("// ") { } else if l.starts_with("// ") {
let (_, test_content) = l.split_at("// ".len()); let (_, test_content) = l.split_at("// ".len());
curr_test_contents.push(test_content); curr_test_contents.push(ExpectedLine::Text(test_content));
} }
} }
} }
@ -2264,7 +2268,7 @@ actual:\n\
} }
} }
fn compare_mir_test_output(&self, test_name: &str, expected_content: &[&str]) { fn compare_mir_test_output(&self, test_name: &str, expected_content: &[ExpectedLine<&str>]) {
let mut output_file = PathBuf::new(); let mut output_file = PathBuf::new();
output_file.push(self.get_mir_dump_dir()); output_file.push(self.get_mir_dump_dir());
output_file.push(test_name); output_file.push(test_name);
@ -2276,38 +2280,77 @@ actual:\n\
let mut dumped_string = String::new(); let mut dumped_string = String::new();
dumped_file.read_to_string(&mut dumped_string).unwrap(); dumped_file.read_to_string(&mut dumped_string).unwrap();
let mut dumped_lines = dumped_string.lines().filter(|l| !l.is_empty()); let mut dumped_lines = dumped_string.lines().filter(|l| !l.is_empty());
let mut expected_lines = expected_content.iter().filter(|l| !l.is_empty()); let mut expected_lines = expected_content.iter().filter(|&l| {
if let &ExpectedLine::Text(l) = l {
// We expect each non-empty line from expected_content to appear !l.is_empty()
// in the dump in order, but there may be extra lines interleaved } else {
while let Some(expected_line) = expected_lines.next() { true
let e_norm = normalize_mir_line(expected_line);
if e_norm.is_empty() {
continue;
};
let mut found = false;
while let Some(dumped_line) = dumped_lines.next() {
let d_norm = normalize_mir_line(dumped_line);
debug!("found: {:?}", d_norm);
debug!("expected: {:?}", e_norm);
if e_norm == d_norm {
found = true;
break;
};
} }
if !found { }).peekable();
let normalize_all = dumped_string.lines()
.map(nocomment_mir_line) let compare = |expected_line, dumped_line| {
.filter(|l| !l.is_empty()) let e_norm = normalize_mir_line(expected_line);
.collect::<Vec<_>>() let d_norm = normalize_mir_line(dumped_line);
.join("\n"); debug!("found: {:?}", d_norm);
panic!("ran out of mir dump output to match against.\n\ debug!("expected: {:?}", e_norm);
Did not find expected line: {:?}\n\ e_norm == d_norm
Expected:\n{}\n\ };
Actual:\n{}",
expected_line, let error = |expected_line, extra_msg| {
expected_content.join("\n"), let normalize_all = dumped_string.lines()
normalize_all); .map(nocomment_mir_line)
.filter(|l| !l.is_empty())
.collect::<Vec<_>>()
.join("\n");
let f = |l: &ExpectedLine<_>| match l {
&ExpectedLine::Elision => "... (elided)".into(),
&ExpectedLine::Text(t) => t
};
let expected_content = expected_content.iter()
.map(|l| f(l))
.collect::<Vec<_>>()
.join("\n");
panic!("Did not find expected line, error: {}\n\
Actual Line: {:?}\n\
Expected:\n{}\n\
Actual:\n{}",
extra_msg,
expected_line,
expected_content,
normalize_all);
};
// We expect each non-empty line to appear consecutively, non-consecutive lines
// must be separated by at least one Elision
while let Some(dumped_line) = dumped_lines.next() {
match expected_lines.next() {
Some(&ExpectedLine::Text(expected_line)) =>
if !compare(expected_line, dumped_line) {
error(expected_line,
format!("Mismatch in lines\nExpected Line: {:?}", dumped_line));
},
Some(&ExpectedLine::Elision) => {
// skip any number of elisions in a row.
while let Some(&&ExpectedLine::Elision) = expected_lines.peek() {
expected_lines.next();
}
if let Some(&ExpectedLine::Text(expected_line)) = expected_lines.next() {
let mut found = compare(expected_line, dumped_line);
if found {
continue;
}
while let Some(dumped_line) = dumped_lines.next() {
found = compare(expected_line, dumped_line);
if found {
break;
}
}
if !found {
error(expected_line, "ran out of mir dump to match against".into());
}
}
},
None => {},
} }
} }
} }
@ -2430,6 +2473,25 @@ enum TargetLocation {
ThisDirectory(PathBuf), ThisDirectory(PathBuf),
} }
#[derive(Clone, PartialEq, Eq)]
enum ExpectedLine<T: AsRef<str>> {
Elision,
Text(T)
}
impl<T> fmt::Debug for ExpectedLine<T>
where
T: AsRef<str> + fmt::Debug
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if let &ExpectedLine::Text(ref t) = self {
write!(formatter, "{:?}", t)
} else {
write!(formatter, "\"...\" (Elision)")
}
}
}
fn normalize_mir_line(line: &str) -> String { fn normalize_mir_line(line: &str) -> String {
nocomment_mir_line(line).replace(char::is_whitespace, "") nocomment_mir_line(line).replace(char::is_whitespace, "")
} }