Suggest async {}
for async || {}
#76011
Labels
A-async-await
Area: Async & Await
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
This code (playground):
prints out
This is pretty unhelpful for beginners - normally this happens when they try to use
await
in a closure, which tells them they need async:But when they do they get an error about async being unstable, which they have no idea how to solve. The fix is to remove the pipe symbols:
However, this requires knowledge that async blocks desugar internally into closures, which is not at all clear from the syntax. It would be better for the compiler to suggest it:
The text was updated successfully, but these errors were encountered: