2017-10-25 22:04:57 +00:00
|
|
|
// Basic test for liveness constraints: the region (`R1`) that appears
|
|
|
|
// in the type of `p` includes the points after `&v[0]` up to (but not
|
|
|
|
// including) the call to `use_x`. The `else` branch is not included.
|
|
|
|
|
2018-04-09 09:28:00 +00:00
|
|
|
// compile-flags:-Zborrowck=mir -Zverbose
|
|
|
|
// ^^^^^^^^^ force compiler to dump more region information
|
2017-10-25 22:04:57 +00:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
|
|
|
|
fn use_x(_: usize) -> bool { true }
|
|
|
|
|
2020-04-04 17:15:01 +00:00
|
|
|
// EMIT_MIR rustc.main.nll.0.mir
|
2017-10-25 22:04:57 +00:00
|
|
|
fn main() {
|
|
|
|
let mut v = [1, 2, 3];
|
|
|
|
let p = &v[0];
|
|
|
|
let q = p;
|
|
|
|
if true {
|
|
|
|
use_x(*q);
|
|
|
|
} else {
|
|
|
|
use_x(22);
|
|
|
|
}
|
|
|
|
}
|