|
| 1 | +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +// compile-flags:-Znll |
| 12 | + |
| 13 | +fn can_panic() -> Box<usize> { |
| 14 | + Box::new(44) |
| 15 | +} |
| 16 | + |
| 17 | +fn main() { |
| 18 | + let mut x = Box::new(22); |
| 19 | + x = can_panic(); |
| 20 | +} |
| 21 | + |
| 22 | +// Check that: |
| 23 | +// - `_1` is the variable corresponding to `x` |
| 24 | +// and |
| 25 | +// - `_1` is live when `can_panic` is called (because it may be dropped) |
| 26 | +// |
| 27 | +// END RUST SOURCE |
| 28 | +// START rustc.node12.nll.0.mir |
| 29 | +// | Variables live on entry to the block bb0: |
| 30 | +// bb0: { |
| 31 | +// StorageLive(_1); // scope 1 at /Users/nmatsakis/versioned/rust-3/src/test/mir-opt/nll/liveness-call-subtlety.rs:18:9: 18:14 |
| 32 | +// _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 |
| 33 | +// } |
| 34 | +// END rustc.node12.nll.0.mir |
| 35 | +// START rustc.node12.nll.0.mir |
| 36 | +// | Variables live on entry to the block bb1: |
| 37 | +// | - _1 |
| 38 | +// bb1: { |
| 39 | +// StorageLive(_2); // scope 1 at /Users/nmatsakis/versioned/rust-3/src/test/mir-opt/nll/liveness-call-subtlety.rs:19:9: 19:20 |
| 40 | +// _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 |
| 41 | +// } |
| 42 | +// END rustc.node12.nll.0.mir |
0 commit comments