Closed
Description
E0373 help suggests appending move
in front of async closures:
error[E0373]: closure may outlive the current function, but it borrows `n`, which is owned by the current function
--> src/main.rs:10:19
|
10 | Box::pin((async || {
| ^^^^^^^^ may outlive borrowed value `n`
11 | Some((n, n + 1))
| - `n` is borrowed here
|
note: closure is returned here
--> src/main.rs:10:9
|
10 | / Box::pin((async || {
11 | | Some((n, n + 1))
12 | | })())
| |_____________^
help: to force the closure to take ownership of `n` (and any other referenced variables), use the `move` keyword
|
10 | Box::pin((move async || {
| ^^^^^^^^^^^^^
but move async
is not in the correct order:
error: expected one of `|` or `||`, found `async`
--> src/main.rs:10:24
|
10 | Box::pin((move async || {
| ^^^^^ expected one of `|` or `||` here
The suggestion should be async move || { ...
instead.
Meta: rustc 1.37.0-nightly (4edff843d 2019-06-16)