check if the type of a local variable contains illegal region
also, try to suppress some of the duplicate errors---in general more work is needed to make these error messages comprehensible to ordinary humans
This commit is contained in:
parent
7df7a9d8ac
commit
9c7b74b025
8 changed files with 115 additions and 71 deletions
14
src/test/compile-fail/regions-escape-loop-via-variable.rs
Normal file
14
src/test/compile-fail/regions-escape-loop-via-variable.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
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 = //! ERROR reference is not valid
|
||||
&x;
|
||||
|
||||
loop {
|
||||
let x = 1 + *p;
|
||||
p = &x;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue