Don't claim that locals in a function are declared outside of the
function body
This commit is contained in:
parent
fcd0cd0ade
commit
6e425219f1
2 changed files with 11 additions and 6 deletions
|
|
@ -1,12 +1,13 @@
|
|||
error: borrowed data escapes outside of function
|
||||
error: unsatisfied lifetime constraints
|
||||
--> $DIR/regions-infer-paramd-indirect.rs:33:9
|
||||
|
|
||||
LL | impl<'a> set_f<'a> for c<'a> {
|
||||
| -- lifetime `'a` defined here
|
||||
...
|
||||
LL | fn set_f_bad(&mut self, b: Box<b>) {
|
||||
| --------- - `b` is a reference that is only valid in the function body
|
||||
| |
|
||||
| `self` is declared here, outside of the function body
|
||||
| - has type `std::boxed::Box<std::boxed::Box<&'1 isize>>`
|
||||
LL | self.f = b;
|
||||
| ^^^^^^ `b` escapes the function body here
|
||||
| ^^^^^^ assignment requires that `'1` must outlive `'a`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue