Repository navigation
Improve diagnostic for async block passed to AsyncFnOnce - #163167
subhdotsol wants to merge 2 commits into
Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @petrochenkov (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
7ed5391 to
12b50b1
Compare
|
Please disclose whether a LLM was used to write this PR/description. This should probably also be a rustc_on_unimplemented attribute (similar to what the regular Fn traits do) rather than be supported in this way. Is this possible? @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
@mejrs I did not use any LLM to write the PR or the description most of the description was based directly on the original issue and regarding |
Take a look at https://rustc-dev-guide.rust-lang.org/diagnostics.html#rustc_on_unimplemented . You can probably use the |
|
@rustbot ready |
I've taken a look and I'd prefer if this was done through the Can you add support for using Then you can simply add @rustbot author |
|
r? me |
|
Why did you add that "Tests" list to your PR description, @subhdotsol? Why does it name a test that was not diffed at all in this PR? |
|
@mejrs cool i will have a look and add support for |
|
I'm not sure how easy it would be to support parsing that with a space inbetween (happens in |
Closes #163137.
When an async block is passed where
AsyncFnOnce()is expected, rustc currently reports a generic E0277 error without explaining how to fix the code.For example:
Current Output
This change adds a targeted diagnostic for this case:
The diagnostic is only emitted when the failing type is an async block and the required trait is
AsyncFnOnce.A UI regression test was added for #163137.
Tests:
./x.py test tests/ui/async-await/async-closures/suggest-async-closure-issue-163137.rs --stage 1./x.py test tests/ui/async-await/async-closures/suggest-async-block-issue-140265.rs --stage 1