1
Fork 0
rust/src/test/compile-fail/regions-escape-loop-via-variable.rs

14 lines
292 B
Rust
Raw Normal View History

fn main() {
let x = 3;
// Here, the variable `p` gets inferred to a type with a lifetime
// of the loop body. The regionck then determines that this type
// is invalid.
let mut p = &x;
loop {
let x = 1 + *p;
p = &x; //~ ERROR illegal borrow
}
}