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 10:23:42 -06: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 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
}