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:
parent
ed6a2ebcd6
commit
eae1a35f55
6 changed files with 53 additions and 20 deletions
23
src/test/compile-fail/issue-46036.rs
Normal file
23
src/test/compile-fail/issue-46036.rs
Normal 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() { }
|
|
@ -46,9 +46,12 @@ fn main() {
|
|||
// _3 = &'23_1rs _2;
|
||||
// StorageLive(_5);
|
||||
// _5 = _2;
|
||||
// switchInt(move _5) -> [0u8: bb3, otherwise: bb2];
|
||||
// switchInt(move _5) -> [0u8: bb4, otherwise: bb3];
|
||||
// }
|
||||
// bb2: {
|
||||
// ...
|
||||
// }
|
||||
// bb3: {
|
||||
// _0 = ();
|
||||
// StorageDead(_5);
|
||||
// EndRegion('23_1rs);
|
||||
|
@ -56,7 +59,7 @@ fn main() {
|
|||
// StorageDead(_2);
|
||||
// return;
|
||||
// }
|
||||
// bb3: {
|
||||
// bb4: {
|
||||
// _4 = ();
|
||||
// StorageDead(_5);
|
||||
// StorageLive(_7);
|
||||
|
@ -67,6 +70,6 @@ fn main() {
|
|||
// EndRegion('23_1rs);
|
||||
// StorageDead(_3);
|
||||
// StorageDead(_2);
|
||||
// goto -> bb1;
|
||||
// falseUnwind -> [real: bb1, cleanup: bb2];
|
||||
// }
|
||||
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
|
|
|
@ -48,9 +48,12 @@ fn main() {
|
|||
// _3 = &'26_1rs _1;
|
||||
// StorageLive(_5);
|
||||
// _5 = _1;
|
||||
// switchInt(move _5) -> [0u8: bb3, otherwise: bb2];
|
||||
// switchInt(move _5) -> [0u8: bb4, otherwise: bb3];
|
||||
// }
|
||||
// bb2: {
|
||||
// ...
|
||||
// }
|
||||
// bb3: {
|
||||
// _0 = ();
|
||||
// StorageDead(_5);
|
||||
// EndRegion('26_1rs);
|
||||
|
@ -58,7 +61,7 @@ fn main() {
|
|||
// StorageDead(_1);
|
||||
// return;
|
||||
// }
|
||||
// bb3: {
|
||||
// bb4: {
|
||||
// _4 = ();
|
||||
// StorageDead(_5);
|
||||
// StorageLive(_7);
|
||||
|
@ -68,6 +71,6 @@ fn main() {
|
|||
// StorageDead(_7);
|
||||
// EndRegion('26_1rs);
|
||||
// StorageDead(_3);
|
||||
// goto -> bb1;
|
||||
// falseUnwind -> [real: bb1, cleanup: bb2];
|
||||
// }
|
||||
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
|
|
|
@ -58,15 +58,17 @@ fn main() {
|
|||
// StorageLive(_2);
|
||||
// _2 = const 3i32;
|
||||
// StorageLive(_4);
|
||||
// goto -> bb1;
|
||||
// goto -> bb2;
|
||||
// }
|
||||
//
|
||||
// bb1: {
|
||||
// StorageLive(_7);
|
||||
// _7 = _1;
|
||||
// switchInt(move _7) -> [0u8: bb3, otherwise: bb2];
|
||||
// ...
|
||||
// }
|
||||
// bb2: {
|
||||
// StorageLive(_7);
|
||||
// _7 = _1;
|
||||
// switchInt(move _7) -> [0u8: bb4, otherwise: bb3];
|
||||
// }
|
||||
// bb3: {
|
||||
// _0 = ();
|
||||
// StorageDead(_7);
|
||||
// EndRegion('33_0rs);
|
||||
|
@ -75,13 +77,13 @@ fn main() {
|
|||
// StorageDead(_1);
|
||||
// return;
|
||||
// }
|
||||
// bb3: {
|
||||
// bb4: {
|
||||
// _4 = &'33_0rs _2;
|
||||
// _6 = ();
|
||||
// StorageDead(_7);
|
||||
// _1 = const true;
|
||||
// _3 = ();
|
||||
// goto -> bb1;
|
||||
// falseUnwind -> [real: bb2, cleanup: bb1];
|
||||
// }
|
||||
// }
|
||||
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
|
|
|
@ -131,7 +131,7 @@ fn query() -> bool { true }
|
|||
// _1 = ();
|
||||
// EndRegion('35_0rs);
|
||||
// StorageDead(_2);
|
||||
// goto -> bb1;
|
||||
// falseUnwind -> [real: bb1, cleanup: bb2];
|
||||
// }
|
||||
// }
|
||||
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
|
|
|
@ -25,27 +25,29 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const false;
|
||||
// goto -> bb1;
|
||||
// goto -> bb2;
|
||||
// }
|
||||
//
|
||||
// bb1: {
|
||||
// resume;
|
||||
// }
|
||||
// bb2: {
|
||||
// StorageLive(_4);
|
||||
// _4 = _1;
|
||||
// switchInt(move _4) -> [0u8: bb3, otherwise: bb2];
|
||||
// switchInt(move _4) -> [0u8: bb4, otherwise: bb3];
|
||||
// }
|
||||
//
|
||||
// bb2: {
|
||||
// bb3: {
|
||||
// _0 = ();
|
||||
// StorageDead(_4);
|
||||
// StorageDead(_1);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// bb3: {
|
||||
// bb4: {
|
||||
// _3 = ();
|
||||
// StorageDead(_4);
|
||||
// _1 = const true;
|
||||
// _2 = ();
|
||||
// goto -> bb1;
|
||||
// falseUnwind -> [real: bb2, cleanup: bb1];
|
||||
// }
|
||||
// END rustc.main.SimplifyCfg-initial.after.mir
|
||||
|
|
Loading…
Reference in a new issue