Wrongly typing a collect with async streams causes confusing error messages alongside a cascade of unhelpful error messages #85132
Labels
A-async-await
Area: Async & Await
A-diagnostics
Area: Messages for errors, warnings, and lints
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.
Given the following code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=05ab45beb0f9d4f2f7cdd9fc89f17a03
The current output is:
Ideally the output should look like:
I guess just the first error shows what the problem is, but it's still a bit scary for a newcomer. Perhaps a nice sentence like "Collect expected a stream of strings, but got a stream of unity types ()"
Even better would be a suggestion to remove the semicolon so that strings are returned, but I can understand that that analysis may be very complex, and it may be hard to avoid making suggestions that are not what the user intended.
The cascade is somewhat similar to #85131 but unlike with #85131, where the main error message is already decent, I think the main error could also be made a bit better here.
The text was updated successfully, but these errors were encountered: