rust/src/test/compile-fail/regions-leaking-ptr.rs

19 lines
551 B
Rust
Raw Normal View History

// The type of `y` ends up getting inferred to the type of the block.
// This generates a ton of error msgs at the moment.
fn broken() -> int {
let mut x = 3;
let mut y = [&x]; //! ERROR reference is not valid
while x < 10 {
let z = x;
y += [&z];
x += 1;
}
vec::foldl(0, y) {|v, p| v + *p }
//!^ ERROR reference is not valid
//!^^ ERROR reference is not valid
//!^^^ ERROR reference is not valid
//!^^^^ ERROR reference is not valid
//!^^^^^ ERROR reference is not valid
}
fn main() { }