mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
14 lines
313 B
Rust
14 lines
313 B
Rust
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 `x` does not live long enough
|
|
}
|