Closed
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
Area: Async & AwaitArea: Messages for errors, warnings, and lintsAsync-await issues that are part of the "polish" areaAsync-await issues that have been triaged during a working group meeting.Diagnostics: Confusing error or lint that should be reworked.Relevant to the compiler team, which will review and decide on the PR/issue.