Ask questionsE0373 help suggests `move async` but the correct syntax is `async move`
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)
Answer
questions
estebank
Marking as "deferred" because async closures are not a candidate for stabilization
@cramertj if we're making the suggestion now then it is wrong and we should at least hide it. Users will get confused if they are offered a feature that is not yet stable, and even worse offered it with the wrong syntax.
cc @rust-lang/wg-diagnostics
Related questions