2012-12-10 17:32:48 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-04-23 00:59:42 +02:00
|
|
|
// Test no-special rooting is used for managed boxes
|
2012-07-26 08:51:57 -07:00
|
|
|
|
2013-12-11 23:17:54 -08:00
|
|
|
|
2014-06-11 19:33:52 -07:00
|
|
|
use std::gc::GC;
|
|
|
|
|
2012-07-26 08:51:57 -07:00
|
|
|
fn testfn(cond: bool) {
|
2014-04-21 17:58:52 -04:00
|
|
|
let mut x = box(GC) 3i;
|
|
|
|
let mut y = box(GC) 4i;
|
2012-07-26 08:51:57 -07:00
|
|
|
|
|
|
|
let mut a = &*x;
|
|
|
|
|
2014-04-21 17:58:52 -04:00
|
|
|
let mut exp = 3i;
|
2012-07-26 08:51:57 -07:00
|
|
|
if cond {
|
|
|
|
a = &*y;
|
|
|
|
|
|
|
|
exp = 4;
|
|
|
|
}
|
|
|
|
|
2014-04-21 17:58:52 -04:00
|
|
|
x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed
|
|
|
|
y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(*a, exp);
|
2014-04-21 17:58:52 -04:00
|
|
|
assert_eq!(x, box(GC) 5i);
|
|
|
|
assert_eq!(y, box(GC) 6i);
|
2012-07-26 08:51:57 -07:00
|
|
|
}
|
|
|
|
|
2014-04-23 00:59:42 +02:00
|
|
|
pub fn main() {}
|