Skip to content

feat(rustc_trait_selection): suggest .await on future in E0277 - #159626

Open
DAstapov wants to merge 1 commit into
rust-lang:mainfrom
DAstapov:fix/159484
Open

feat(rustc_trait_selection): suggest .await on future in E0277#159626
DAstapov wants to merge 1 commit into
rust-lang:mainfrom
DAstapov:fix/159484

Conversation

@DAstapov

@DAstapov DAstapov commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Closes #159484

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 20, 2026
@rustbot

rustbot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, types
  • compiler, types expanded to 74 candidates
  • Random selection from 17 candidates

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems OK, is this what you had in mind

r? estebank

View changes since this review

@rustbot rustbot assigned estebank and unassigned folkertdev Jul 21, 2026
found: Option<&'hir hir::LetStmt<'hir>>,
}

impl<'a, 'hir> Visitor<'hir> for FindLetVisitor<'a, 'hir> {

@chenyukang chenyukang Jul 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
    }
}

View changes since the review

)],
Applicability::MaybeIncorrect,
);
} else {

@chenyukang chenyukang Jul 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest awaiting impl Future value being printed

5 participants