rust/tests/ui/regions/account-for-lifetimes-in-closure-suggestion.stderr
Esteban Küber a2298a6f19 Do not ICE when suggesting dereferencing closure arg
Account for `for` lifetimes when constructing closure to see if dereferencing the return value would be valid.

Fix #125634, fix #124563.
2024-06-24 03:39:54 +00:00

18 lines
778 B
Plaintext

error: lifetime may not live long enough
--> $DIR/account-for-lifetimes-in-closure-suggestion.rs:13:22
|
LL | Thing.enter_scope(|ctx| {
| ---
| |
| has type `TwoThings<'_, '1>`
| has type `TwoThings<'2, '_>`
LL | SameLifetime(ctx);
| ^^^ this usage requires that `'1` must outlive `'2`
|
= note: requirement occurs because of the type `TwoThings<'_, '_>`, which makes the generic argument `'_` invariant
= note: the struct `TwoThings<'a, 'b>` is invariant over the parameter `'a`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to 1 previous error