rust/src/test/compile-fail/regions-escape-loop-via-vec.rs

13 lines
303 B
Rust
Raw Normal View History

// The type of `y` ends up getting inferred to the type of the block.
fn broken() -> int {
let mut x = 3;
let mut y = ~[&mut x];
while x < 10 {
let mut z = x;
y += ~[&mut z]; //~ ERROR illegal borrow
x += 1;
}
2012-06-30 18:19:07 -05:00
vec::foldl(0, y, |v, p| v + *p )
}
fn main() { }