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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
508 B
Rust
Raw Normal View History

//@ run-pass
use std::mem::swap;
2013-05-06 04:42:54 +00:00
pub fn main() {
let mut x = 4;
for i in 0_usize..3 {
// ensure that the borrow in this alt
2014-08-01 23:42:13 +00: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 19:34:08 +00:00
match i {
i => {
let y = &x;
assert!(i < *y);
}
}
let mut y = 4;
swap(&mut y, &mut x);
}
}