rust/tests/ui/async-await/async-closures/not-lending.stderr
2024-02-06 02:22:58 +00:00

25 lines
1.2 KiB
Plaintext

error: lifetime may not live long enough
--> $DIR/not-lending.rs:14:42
|
LL | let x = async move || -> &String { &s };
| ------------------------ ^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of async closure `{async closure body@$DIR/not-lending.rs:14:42: 14:48}` contains a lifetime `'2`
| lifetime `'1` represents this closure's body
|
= note: closure implements `Fn`, so references to captured variables can't escape the closure
error: lifetime may not live long enough
--> $DIR/not-lending.rs:18:31
|
LL | let x = async move || { &s };
| ------------- ^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of async closure `{async closure body@$DIR/not-lending.rs:18:31: 18:37}` contains a lifetime `'2`
| lifetime `'1` represents this closure's body
|
= note: closure implements `Fn`, so references to captured variables can't escape the closure
error: aborting due to 2 previous errors