-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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)
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.