Inconsistent move behavior in closure with async block #81653
Labels
A-async-await
Area: Async & Await
A-closures
Area: closures (`|args| { .. }`)
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
C-bug
Category: This is a bug.
E-needs-mentor
Call for participation: This issue is in need of a mentor.
Projects
This closure fails to compile:
I'd expect that this would compile -
val
should be moved into the async closure.This is inconsistent with the following cases where it compiles (playground link):
val
to a!Copy
type (such asString
)async
keywordThis has a serious drawback in that it forces you to use
async move
even 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
NonCopy
newtype.Meta
This happens on Stable, Nightly, and Beta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: