-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 suggestion for missing .await
keyword
#62067
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@matthewjasper Thank you very much for the comments! I hope this covers everything you suggested. |
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've left a couple nit-picky reviews that you can feel free to resolve if you have the time, this looks great though!
@davidtwco Thank you for the review! I've tried my best to follow your guidance. I've rebased, but haven't made any semantic changes. |
@bors r+ |
📌 Commit 86ffeef has been approved by |
🌲 The tree is currently closed for pull requests below priority 999, this pull request will be tested once the tree is reopened |
…jasper Add suggestion for missing `.await` keyword This commit adds a suggestion diagnostic for missing `.await`. In order to do this, the trait `Future` is promoted to a lang item. Compiling code of the form: ```rust #![feature(async_await)] fn take_u32(x: u32) {} async fn make_u32() -> u32 { 22 } async fn foo() { let x = make_u32(); take_u32(x) } fn main() {} ``` Will now result in the suggestion: ``` error[E0308]: mismatched types --> src/main.rs:11:18 | 11 | take_u32(x) | ^ | | | expected u32, found opaque type | help: consider using `.await` here: `x.await` | = note: expected type `u32` found type `impl std::future::Future` ``` This commit does not cover chained expressions and therefore only covers the case originally pointed out in rust-lang#61076. Cases I can think of that still need to be covered: - [ ] Return places for functions - [ ] Field access - [ ] Method invocation I'm planning to submit PRs for each of these separately as and when I have figured them out.
Failed in #62178 (comment), @bors r- |
I hadn't realised that the API for HIR had changed, this should hopefully be alright to merge now (the only change in that rebase is to change |
@bors r=matthewjasper |
📌 Commit 8819420 has been approved by |
…jasper Add suggestion for missing `.await` keyword This commit adds a suggestion diagnostic for missing `.await`. In order to do this, the trait `Future` is promoted to a lang item. Compiling code of the form: ```rust #![feature(async_await)] fn take_u32(x: u32) {} async fn make_u32() -> u32 { 22 } async fn foo() { let x = make_u32(); take_u32(x) } fn main() {} ``` Will now result in the suggestion: ``` error[E0308]: mismatched types --> src/main.rs:11:18 | 11 | take_u32(x) | ^ | | | expected u32, found opaque type | help: consider using `.await` here: `x.await` | = note: expected type `u32` found type `impl std::future::Future` ``` This commit does not cover chained expressions and therefore only covers the case originally pointed out in rust-lang#61076. Cases I can think of that still need to be covered: - [ ] Return places for functions - [ ] Field access - [ ] Method invocation I'm planning to submit PRs for each of these separately as and when I have figured them out.
…jasper Add suggestion for missing `.await` keyword This commit adds a suggestion diagnostic for missing `.await`. In order to do this, the trait `Future` is promoted to a lang item. Compiling code of the form: ```rust #![feature(async_await)] fn take_u32(x: u32) {} async fn make_u32() -> u32 { 22 } async fn foo() { let x = make_u32(); take_u32(x) } fn main() {} ``` Will now result in the suggestion: ``` error[E0308]: mismatched types --> src/main.rs:11:18 | 11 | take_u32(x) | ^ | | | expected u32, found opaque type | help: consider using `.await` here: `x.await` | = note: expected type `u32` found type `impl std::future::Future` ``` This commit does not cover chained expressions and therefore only covers the case originally pointed out in rust-lang#61076. Cases I can think of that still need to be covered: - [ ] Return places for functions - [ ] Field access - [ ] Method invocation I'm planning to submit PRs for each of these separately as and when I have figured them out.
Rollup of 16 pull requests Successful merges: - #61878 (improve pinning projection docs) - #62043 (Remove `FnBox`) - #62067 (Add suggestion for missing `.await` keyword) - #62076 (Updated RELEASES.md for 1.36.0) - #62102 (call out explicitly that general read needs to be called with an initialized buffer) - #62106 (Add more tests for async/await) - #62124 (refactor lexer to use idiomatic borrowing) - #62131 (libsyntax: Fix some Clippy warnings) - #62152 (Don't ICE on item in `.await` expression) - #62154 (Remove old fixme) - #62155 (Add regression test for MIR drop generation in async loops) - #62156 (Update books) - #62160 (Remove outdated question_mark_macro_sep lint) - #62164 (save-analysis: use buffered writes) - #62171 (rustc: Retry SIGILL linker invocations) - #62176 (Update RLS) Failed merges: r? @ghost
This commit adds a suggestion diagnostic for missing
.await
. In order to do this, the traitFuture
is promoted to a lang item.Compiling code of the form:
Will now result in the suggestion:
This commit does not cover chained expressions and therefore only covers the case originally pointed out in #61076. Cases I can think of that still need to be covered:
I'm planning to submit PRs for each of these separately as and when I have figured them out.