feat(rustc_trait_selection): suggest .await on future in E0277 - #159626
feat(rustc_trait_selection): suggest .await on future in E0277#159626DAstapov wants to merge 1 commit into
.await on future in E0277#159626Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @folkertdev (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 (
Why was this reviewer chosen?The reviewer was selected based on:
|
| found: Option<&'hir hir::LetStmt<'hir>>, | ||
| } | ||
|
|
||
| impl<'a, 'hir> Visitor<'hir> for FindLetVisitor<'a, 'hir> { |
There was a problem hiding this comment.
Scanning the entire body by textual name can select an unrelated shadowed binding and insert .await on a non-Future value.
for example:
async fn make_number() -> i32 {
42
}
async fn f() {
let number = make_number();
println!("{number}");
{
let number = 0;
}
}| )], | ||
| Applicability::MaybeIncorrect, | ||
| ); | ||
| } else { |
There was a problem hiding this comment.
This fallback can still be reached for a captured format argument when the binding is not a top-level PatKind::Binding, for example:
async fn show() {
let (number,) = (make_number(),);
println!("{number}");
}Here span is still inside the format string, so the suggestion produces println!("{number}.await"), which does not actually await the future.
Closes #159484