rust/tests/ui/span/regions-escape-loop-via-variable.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
313 B
Rust
Raw Normal View History

fn main() {
2015-01-31 16:23:42 +00:00
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 {
2015-01-31 16:23:42 +00:00
let x = 1 + *p;
2017-11-20 12:13:27 +00:00
p = &x;
2017-12-14 01:27:23 +00:00
}
//~^^ ERROR `x` does not live long enough
}