]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/borrowck-preserve-cond-box.rs
Imported Upstream version 0.6
[rustc.git] / src / test / run-pass / borrowck-preserve-cond-box.rs
1 // Copyright 2012 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 // exec-env:RUST_POISON_ON_FREE=1
12
13 fn testfn(cond: bool) {
14 let mut x = @3;
15 let mut y = @4;
16
17 // borrow x and y
18 let mut r_x = &*x;
19 let mut r_y = &*y;
20 let mut r = r_x, exp = 3;
21
22 if cond {
23 r = r_y;
24 exp = 4;
25 }
26
27 debug!("*r = %d, exp = %d", *r, exp);
28 assert!(*r == exp);
29
30 x = @5;
31 y = @6;
32
33 debug!("*r = %d, exp = %d", *r, exp);
34 assert!(*r == exp);
35 }
36
37 pub fn main() {
38 testfn(true);
39 testfn(false);
40 }