Files
rust/tests/ui/regions/regions-infer-borrow-scope-addr-of.rs

24 lines
508 B
Rust
Raw Normal View History

//@ run-pass
use std::mem::swap;
2013-05-06 00:42:54 -04:00
pub fn main() {
let mut x = 4;
for i in 0_usize..3 {
// ensure that the borrow in this alt
2014-08-01 19:42:13 -04:00
// does not interfere with the swap
// below. note that it would it you
// naively borrowed &x for the lifetime
// of the variable x, as we once did
2012-08-06 12:34:08 -07:00
match i {
i => {
let y = &x;
assert!(i < *y);
}
}
let mut y = 4;
swap(&mut y, &mut x);
}
}