2012-05-15 21:19:35 -07:00
|
|
|
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.
|
2012-06-30 12:23:59 +01:00
|
|
|
let mut p = //~ ERROR reference is not valid
|
2012-05-15 21:19:35 -07:00
|
|
|
&x;
|
|
|
|
|
|
|
|
loop {
|
|
|
|
let x = 1 + *p;
|
|
|
|
p = &x;
|
|
|
|
}
|
|
|
|
}
|