]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-infer-borrow-scope-addr-of.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-infer-borrow-scope-addr-of.rs
1 // run-pass
2
3 use std::mem::swap;
4
5 pub fn main() {
6     let mut x = 4;
7
8     for i in 0_usize..3 {
9         // ensure that the borrow in this alt
10         // does not interfere with the swap
11         // below.  note that it would it you
12         // naively borrowed &x for the lifetime
13         // of the variable x, as we once did
14         match i {
15             i => {
16                 let y = &x;
17                 assert!(i < *y);
18             }
19         }
20         let mut y = 4;
21         swap(&mut y, &mut x);
22     }
23 }