2012-07-06 09:14:57 -07:00
|
|
|
fn borrow<T>(x: &T) -> &T {x}
|
|
|
|
|
2012-07-26 08:51:57 -07: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.
|
|
|
|
y = borrow(x); //~ ERROR managed value would have to be rooted for lifetime
|
|
|
|
|
2012-07-06 09:14:57 -07:00
|
|
|
assert *x == *y;
|
2012-07-26 08:51:57 -07:00
|
|
|
if cond() { break; }
|
2012-07-06 09:14:57 -07:00
|
|
|
}
|
2012-07-26 08:51:57 -07:00
|
|
|
assert *y != 0;
|
2012-07-06 09:14:57 -07:00
|
|
|
}
|
2012-07-26 08:51:57 -07:00
|
|
|
|
|
|
|
fn main() {}
|