2012-07-06 11:14:57 -05:00
|
|
|
fn borrow<T>(x: &T) -> &T {x}
|
|
|
|
|
2012-07-26 10:51:57 -05:00
|
|
|
fn foo(cond: fn() -> bool, box: fn() -> @int) {
|
|
|
|
let mut y: ∫
|
|
|
|
loop {
|
|
|
|
let x = box();
|
|
|
|
|
|
|
|
// Here we complain because the resulting region
|
|
|
|
// of this borrow is the fn body as a whole.
|
2012-08-07 21:48:24 -05:00
|
|
|
y = borrow(x); //~ ERROR illegal borrow: managed value would have to be rooted
|
2012-07-26 10:51:57 -05:00
|
|
|
|
2012-07-06 11:14:57 -05:00
|
|
|
assert *x == *y;
|
2012-07-26 10:51:57 -05:00
|
|
|
if cond() { break; }
|
2012-07-06 11:14:57 -05:00
|
|
|
}
|
2012-07-26 10:51:57 -05:00
|
|
|
assert *y != 0;
|
2012-07-06 11:14:57 -05:00
|
|
|
}
|
2012-07-26 10:51:57 -05:00
|
|
|
|
|
|
|
fn main() {}
|