2012-05-15 23:19:35 -05:00
|
|
|
fn main() {
|
2015-01-31 10:23:42 -06:00
|
|
|
let x = 3;
|
2012-05-15 23:19:35 -05:00
|
|
|
|
|
|
|
// 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-07-26 10:51:57 -05:00
|
|
|
let mut p = &x;
|
2012-05-15 23:19:35 -05:00
|
|
|
|
|
|
|
loop {
|
2015-01-31 10:23:42 -06:00
|
|
|
let x = 1 + *p;
|
2017-11-20 06:13:27 -06:00
|
|
|
p = &x;
|
2017-12-13 19:27:23 -06:00
|
|
|
}
|
|
|
|
//~^^ ERROR `x` does not live long enough
|
2012-05-15 23:19:35 -05:00
|
|
|
}
|