-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.
Description
Trying to setup async closures and it took awhile to figure out what was happening.
It is when types are defined as Box<dyn Fn() -> (dyn Future<Output = ()>)>
More can be seen here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7eab934ef04fb7171121c4e4180f7f4d
The current output is:
12 | async fn message_unboxed(value: UnboxedAsync) {
| ----- `value` has type `Box<dyn Fn() -> (dyn Future<Output = ()> + 'static)>`
13 | // call expression requires function
14 | value().await;
| ^^^^^--
| |
| call expression requires function
Above was apparently caused by lack of Pin<Box<_>>
on the future. Once added it works fine (also on playground link)
Would be nice if the error was directing me to the return value of the closure.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.