about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbobtwinkles <srkoser+GitHub@gmail.com>2018-01-27 05:18:12 -0500
committerbobtwinkles <srkoser+GitHub@gmail.com>2018-02-05 15:00:40 -0500
commiteae1a35f554aa8149a71181354481b8b7a9b71bb (patch)
treee8e8d81480df5a3d377d345c1f58865844f947c1 /src
parented6a2ebcd6d36f2e0760d419094a653bda984bc2 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/test/compile-fail/issue-46036.rs23
-rw-r--r--src/test/mir-opt/end_region_2.rs9
-rw-r--r--src/test/mir-opt/end_region_3.rs9
-rw-r--r--src/test/mir-opt/end_region_9.rs14
-rw-r--r--src/test/mir-opt/end_region_cyclic.rs2
-rw-r--r--src/test/mir-opt/issue-38669.rs14
6 files changed, 52 insertions, 19 deletions
diff --git a/src/test/compile-fail/issue-46036.rs b/src/test/compile-fail/issue-46036.rs
new file mode 100644
index 00000000000..b5cdded4d30
--- /dev/null
+++ b/src/test/compile-fail/issue-46036.rs
@@ -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() { }
diff --git a/src/test/mir-opt/end_region_2.rs b/src/test/mir-opt/end_region_2.rs
index 56c3e2a38a0..958e9364c8f 100644
--- a/src/test/mir-opt/end_region_2.rs
+++ b/src/test/mir-opt/end_region_2.rs
@@ -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
diff --git a/src/test/mir-opt/end_region_3.rs b/src/test/mir-opt/end_region_3.rs
index 8c0d56eba78..c1ebc525e88 100644
--- a/src/test/mir-opt/end_region_3.rs
+++ b/src/test/mir-opt/end_region_3.rs
@@ -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
diff --git a/src/test/mir-opt/end_region_9.rs b/src/test/mir-opt/end_region_9.rs
index b313e296ac9..70611306fd3 100644
--- a/src/test/mir-opt/end_region_9.rs
+++ b/src/test/mir-opt/end_region_9.rs
@@ -58,15 +58,17 @@ fn main() {
 //        StorageLive(_2);
 //        _2 = const 3i32;
 //        StorageLive(_4);
-//        goto -> bb1;
+//        goto -> bb2;
 //    }
-//
 //    bb1: {
+//        ...
+//    }
+//    bb2: {
 //        StorageLive(_7);
 //        _7 = _1;
-//        switchInt(move _7) -> [0u8: bb3, otherwise: bb2];
+//        switchInt(move _7) -> [0u8: bb4, otherwise: bb3];
 //    }
-//    bb2: {
+//    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
diff --git a/src/test/mir-opt/end_region_cyclic.rs b/src/test/mir-opt/end_region_cyclic.rs
index 37a6229feba..801c4eed4d2 100644
--- a/src/test/mir-opt/end_region_cyclic.rs
+++ b/src/test/mir-opt/end_region_cyclic.rs
@@ -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
diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs
index b5c188cf834..4444d96798f 100644
--- a/src/test/mir-opt/issue-38669.rs
+++ b/src/test/mir-opt/issue-38669.rs
@@ -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