mir: Add and fix tests for FalseUnwinds

Fix instructions on existing mir-opt tests after introducing false edges from
loops. Also, add a test for issue 46036: infinite loops.
This commit is contained in:
bobtwinkles 2018-01-27 05:18:12 -05:00
parent ed6a2ebcd6
commit eae1a35f55
6 changed files with 53 additions and 20 deletions

View file

@ -0,0 +1,23 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Issue 46036: [NLL] false edges on infinite loops
// Infinite loops should create false edges to the cleanup block.
#![feature(nll)]
struct Foo { x: &'static u32 }
fn foo() {
let a = 3;
let foo = Foo { x: &a }; //~ ERROR E0597
loop { }
}
fn main() { }

View file

@ -46,9 +46,12 @@ fn main() {
// _3 = &'23_1rs _2; // _3 = &'23_1rs _2;
// StorageLive(_5); // StorageLive(_5);
// _5 = _2; // _5 = _2;
// switchInt(move _5) -> [0u8: bb3, otherwise: bb2]; // switchInt(move _5) -> [0u8: bb4, otherwise: bb3];
// } // }
// bb2: { // bb2: {
// ...
// }
// bb3: {
// _0 = (); // _0 = ();
// StorageDead(_5); // StorageDead(_5);
// EndRegion('23_1rs); // EndRegion('23_1rs);
@ -56,7 +59,7 @@ fn main() {
// StorageDead(_2); // StorageDead(_2);
// return; // return;
// } // }
// bb3: { // bb4: {
// _4 = (); // _4 = ();
// StorageDead(_5); // StorageDead(_5);
// StorageLive(_7); // StorageLive(_7);
@ -67,6 +70,6 @@ fn main() {
// EndRegion('23_1rs); // EndRegion('23_1rs);
// StorageDead(_3); // StorageDead(_3);
// StorageDead(_2); // StorageDead(_2);
// goto -> bb1; // falseUnwind -> [real: bb1, cleanup: bb2];
// } // }
// END rustc.main.SimplifyCfg-qualify-consts.after.mir // END rustc.main.SimplifyCfg-qualify-consts.after.mir

View file

@ -48,9 +48,12 @@ fn main() {
// _3 = &'26_1rs _1; // _3 = &'26_1rs _1;
// StorageLive(_5); // StorageLive(_5);
// _5 = _1; // _5 = _1;
// switchInt(move _5) -> [0u8: bb3, otherwise: bb2]; // switchInt(move _5) -> [0u8: bb4, otherwise: bb3];
// } // }
// bb2: { // bb2: {
// ...
// }
// bb3: {
// _0 = (); // _0 = ();
// StorageDead(_5); // StorageDead(_5);
// EndRegion('26_1rs); // EndRegion('26_1rs);
@ -58,7 +61,7 @@ fn main() {
// StorageDead(_1); // StorageDead(_1);
// return; // return;
// } // }
// bb3: { // bb4: {
// _4 = (); // _4 = ();
// StorageDead(_5); // StorageDead(_5);
// StorageLive(_7); // StorageLive(_7);
@ -68,6 +71,6 @@ fn main() {
// StorageDead(_7); // StorageDead(_7);
// EndRegion('26_1rs); // EndRegion('26_1rs);
// StorageDead(_3); // StorageDead(_3);
// goto -> bb1; // falseUnwind -> [real: bb1, cleanup: bb2];
// } // }
// END rustc.main.SimplifyCfg-qualify-consts.after.mir // END rustc.main.SimplifyCfg-qualify-consts.after.mir

View file

@ -58,15 +58,17 @@ fn main() {
// StorageLive(_2); // StorageLive(_2);
// _2 = const 3i32; // _2 = const 3i32;
// StorageLive(_4); // StorageLive(_4);
// goto -> bb1; // goto -> bb2;
// } // }
//
// bb1: { // bb1: {
// StorageLive(_7); // ...
// _7 = _1;
// switchInt(move _7) -> [0u8: bb3, otherwise: bb2];
// } // }
// bb2: { // bb2: {
// StorageLive(_7);
// _7 = _1;
// switchInt(move _7) -> [0u8: bb4, otherwise: bb3];
// }
// bb3: {
// _0 = (); // _0 = ();
// StorageDead(_7); // StorageDead(_7);
// EndRegion('33_0rs); // EndRegion('33_0rs);
@ -75,13 +77,13 @@ fn main() {
// StorageDead(_1); // StorageDead(_1);
// return; // return;
// } // }
// bb3: { // bb4: {
// _4 = &'33_0rs _2; // _4 = &'33_0rs _2;
// _6 = (); // _6 = ();
// StorageDead(_7); // StorageDead(_7);
// _1 = const true; // _1 = const true;
// _3 = (); // _3 = ();
// goto -> bb1; // falseUnwind -> [real: bb2, cleanup: bb1];
// } // }
// } // }
// END rustc.main.SimplifyCfg-qualify-consts.after.mir // END rustc.main.SimplifyCfg-qualify-consts.after.mir

View file

@ -131,7 +131,7 @@ fn query() -> bool { true }
// _1 = (); // _1 = ();
// EndRegion('35_0rs); // EndRegion('35_0rs);
// StorageDead(_2); // StorageDead(_2);
// goto -> bb1; // falseUnwind -> [real: bb1, cleanup: bb2];
// } // }
// } // }
// END rustc.main.SimplifyCfg-qualify-consts.after.mir // END rustc.main.SimplifyCfg-qualify-consts.after.mir

View file

@ -25,27 +25,29 @@ fn main() {
// bb0: { // bb0: {
// StorageLive(_1); // StorageLive(_1);
// _1 = const false; // _1 = const false;
// goto -> bb1; // goto -> bb2;
// } // }
// //
// bb1: { // bb1: {
// resume;
// }
// bb2: {
// StorageLive(_4); // StorageLive(_4);
// _4 = _1; // _4 = _1;
// switchInt(move _4) -> [0u8: bb3, otherwise: bb2]; // switchInt(move _4) -> [0u8: bb4, otherwise: bb3];
// } // }
// // bb3: {
// bb2: {
// _0 = (); // _0 = ();
// StorageDead(_4); // StorageDead(_4);
// StorageDead(_1); // StorageDead(_1);
// return; // return;
// } // }
// //
// bb3: { // bb4: {
// _3 = (); // _3 = ();
// StorageDead(_4); // StorageDead(_4);
// _1 = const true; // _1 = const true;
// _2 = (); // _2 = ();
// goto -> bb1; // falseUnwind -> [real: bb2, cleanup: bb1];
// } // }
// END rustc.main.SimplifyCfg-initial.after.mir // END rustc.main.SimplifyCfg-initial.after.mir