-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing check for async body when suggesting await on futures. #135492
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @BoxyUwU (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
Outdated
Show resolved
Hide resolved
@rustbot review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls fix this and also squash this into one commit at the end.
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
Outdated
Show resolved
Hide resolved
Did you see my comment? Please squash this into one commit. |
7945d60
to
ab2c8ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont understand the github merge workflow. Sorry. Does the squashed commit I pushed yesterday look ok?
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135073 (Implement `ByteStr` and `ByteString` types) - rust-lang#135492 (Add missing check for async body when suggesting await on futures.) - rust-lang#135766 (handle global trait bounds defining assoc types) - rust-lang#135880 (Get rid of RunCompiler) - rust-lang#135908 (rustc_codegen_llvm: remove outdated asm-to-obj codegen note) - rust-lang#135911 (Allow `arena_cache` queries to return `Option<&'tcx T>`) - rust-lang#135920 (simplify parse_format::Parser::ws by using next_if) r? `@ghost` `@rustbot` modify labels: rollup
Currently the compiler suggests adding
.await
to resolve some type conflicts without checking if the conflict happens in an async context. This can lead to the compiler suggesting.await
in function signatures where it is invalid. Example:The documentation of suggest_await_on_expect_found (
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs:156
) even mentions such a check but does not actually implement it.This PR adds that check to ensure
.await
is only suggested within async blocks.There were 3 unit tests whose expected output needed to be changed because they had the suggestion outside of async. One of them (
tests/ui/async-await/dont-suggest-missing-await.rs
) actually tests that exact problem but expects it to be present.Thanks to @llenck for initially noticing the bug and helping with fixing it