about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-10-24 11:06:58 -0400
committerNiko Matsakis <niko@alum.mit.edu>2017-10-31 12:41:37 -0400
commitacc5c4345c42c7558c15ffdf1e10a20126652c73 (patch)
tree742d60370e2eb6de9bff03084be30d47a7c00c63
parentc42a64518af371fe7cc6b70607b5c35144b96575 (diff)
downloadrust-acc5c4345c42c7558c15ffdf1e10a20126652c73.tar.gz
rust-acc5c4345c42c7558c15ffdf1e10a20126652c73.zip
add a test for the subtle case around calls
-rw-r--r--src/test/mir-opt/nll/liveness-call-subtlety.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/mir-opt/nll/liveness-call-subtlety.rs b/src/test/mir-opt/nll/liveness-call-subtlety.rs
new file mode 100644
index 00000000000..99ed5fe186e
--- /dev/null
+++ b/src/test/mir-opt/nll/liveness-call-subtlety.rs
@@ -0,0 +1,42 @@
+// Copyright 2012-2016 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.
+
+// compile-flags:-Znll
+
+fn can_panic() -> Box<usize> {
+    Box::new(44)
+}
+
+fn main() {
+    let mut x = Box::new(22);
+    x = can_panic();
+}
+
+// Check that:
+// - `_1` is the variable corresponding to `x`
+// and
+// - `_1` is live when `can_panic` is called (because it may be dropped)
+//
+// END RUST SOURCE
+// START rustc.node12.nll.0.mir
+//    | Variables live on entry to the block bb0:
+//    bb0: {
+//        StorageLive(_1);                 // scope 1 at /Users/nmatsakis/versioned/rust-3/src/test/mir-opt/nll/liveness-call-subtlety.rs:18:9: 18:14
+//        _1 = const <std::boxed::Box<T>>::new(const 22usize) -> bb1; // scope 1 at /Users/nmatsakis/versioned/rust-3/src/test/mir-opt/nll/liveness-call-subtlety.rs:18:17: 18:29
+//    }
+// END rustc.node12.nll.0.mir
+// START rustc.node12.nll.0.mir
+//    | Variables live on entry to the block bb1:
+//    | - _1
+//    bb1: {
+//        StorageLive(_2);                 // scope 1 at /Users/nmatsakis/versioned/rust-3/src/test/mir-opt/nll/liveness-call-subtlety.rs:19:9: 19:20
+//        _2 = const can_panic() -> [return: bb2, unwind: bb4]; // scope 1 at /Users/nmatsakis/versioned/rust-3/src/test/mir-opt/nll/liveness-call-subtlety.rs:19:9: 19:20
+//    }
+// END rustc.node12.nll.0.mir