-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Inconsistent move behavior in closure with async block #81653
Copy link
Copy link
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)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.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)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.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
On deck
This closure fails to compile:
I'd expect that this would compile -
valshould be moved into the async closure.This is inconsistent with the following cases where it compiles (playground link):
valto a!Copytype (such asString)asynckeywordThis has a serious drawback in that it forces you to use
async moveeven when you can't move everything into the async block.Workaround
This is super unergonomic, but as a workaround you can surround the copy type with a
NonCopynewtype.Meta
This happens on Stable, Nightly, and Beta
rustc --version --verbose: