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