mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-11 22:43:42 +00:00
![Esteban Küber](/assets/img/avatar_default.png)
Account for `for` lifetimes when constructing closure to see if dereferencing the return value would be valid. Fix #125634, fix #124563.
17 lines
411 B
Plaintext
17 lines
411 B
Plaintext
error: lifetime may not live long enough
|
|
--> $DIR/regions-escape-method.rs:16:13
|
|
|
|
|
LL | s.f(|p| p)
|
|
| -- ^ returning this value requires that `'1` must outlive `'2`
|
|
| ||
|
|
| |return type of closure is &'2 i32
|
|
| has type `&'1 i32`
|
|
|
|
|
help: dereference the return value
|
|
|
|
|
LL | s.f(|p| *p)
|
|
| +
|
|
|
|
error: aborting due to 1 previous error
|
|
|