2012-12-10 19:32:48 -06: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-22 17:59:42 -05:00
|
|
|
// Test no-special rooting is used for managed boxes
|
2012-07-26 10:51:57 -05:00
|
|
|
|
2014-04-14 10:30:31 -05:00
|
|
|
#![feature(managed_boxes)]
|
2013-12-12 01:17:54 -06:00
|
|
|
|
2014-06-11 21:33:52 -05:00
|
|
|
use std::gc::GC;
|
|
|
|
|
2012-07-26 10:51:57 -05:00
|
|
|
fn testfn(cond: bool) {
|
2014-04-21 16:58:52 -05:00
|
|
|
let mut x = box(GC) 3i;
|
|
|
|
let mut y = box(GC) 4i;
|
2012-07-26 10:51:57 -05:00
|
|
|
|
|
|
|
let mut a = &*x;
|
|
|
|
|
2014-04-21 16:58:52 -05:00
|
|
|
let mut exp = 3i;
|
2012-07-26 10:51:57 -05:00
|
|
|
if cond {
|
|
|
|
a = &*y;
|
|
|
|
|
|
|
|
exp = 4;
|
|
|
|
}
|
|
|
|
|
2014-04-21 16:58:52 -05: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 21:02:45 -05:00
|
|
|
assert_eq!(*a, exp);
|
2014-04-21 16:58:52 -05:00
|
|
|
assert_eq!(x, box(GC) 5i);
|
|
|
|
assert_eq!(y, box(GC) 6i);
|
2012-07-26 10:51:57 -05:00
|
|
|
}
|
|
|
|
|
2014-04-22 17:59:42 -05:00
|
|
|
pub fn main() {}
|