Improve error message when trying to use ?
in an async block that does not return a FromResidual type
#94944
Labels
A-async-await
Area: Async & Await
A-diagnostics
Area: Messages for errors, warnings, and lints
AsyncAwait-Polish
Async-await issues that are part of the "polish" area
AsyncAwait-Triaged
Async-await issues that have been triaged during a working group meeting.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Currently, trying to use
?
in a function that does not return a compatible type results in a great error message:However, when the same issue occurs in an async block, the output is not as helpful: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d8fadebcedd4dda50a5377047a6227d7
The current output is:
This is especially unhelpful in the current state of things with FromResidual being an unstable trait with incomplete docs. Ideally the output would look something like:
I'm not sure what the proper terminology here is. It might be that the error message should instead of futures talk about async blocks, and/or instead of returning () talk about resolving to (), the output or Output being (), or something else.
This issue was inspired by the URLO post at https://users.rust-lang.org/t/fromresidual-not-even-in-the-crate-im-using/72980
The text was updated successfully, but these errors were encountered: