Skip to content

Suggest async block instead of async closure when possible#152042

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
chenyukang:yukang-fix-140265-async-closure-suggestion
Mar 1, 2026
Merged

Suggest async block instead of async closure when possible#152042
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
chenyukang:yukang-fix-140265-async-closure-suggestion

Conversation

@chenyukang
Copy link
Member

@chenyukang chenyukang commented Feb 3, 2026

Fixes #140265

r? @estebank

@rustbot rustbot added 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. labels Feb 3, 2026
&& obligation.cause.span.contains(*arg_span)
{
err.span_suggestion_verbose(
arg_span.with_hi(arg_span.hi() + rustc_span::BytePos(1)),
Copy link
Member

Choose a reason for hiding this comment

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

It's an edge-case but the suggestion would be broken if there's no whitespace, like:

takes_future(async||{

@chenyukang chenyukang force-pushed the yukang-fix-140265-async-closure-suggestion branch from ab0f461 to 1a4fcc1 Compare February 5, 2026 10:14
@rust-log-analyzer

This comment has been minimized.

@JohnTitor
Copy link
Member

r=me if you want

@chenyukang
Copy link
Member Author

@bors retry

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 28, 2026

❗ You can only retry pull requests that are approved and have a previously failed auto build.

@chenyukang chenyukang force-pushed the yukang-fix-140265-async-closure-suggestion branch from 1a4fcc1 to 37f4765 Compare February 28, 2026 12:58
@chenyukang
Copy link
Member Author

let me wait whether it's green from CI now.

@chenyukang chenyukang force-pushed the yukang-fix-140265-async-closure-suggestion branch from 37f4765 to 3736458 Compare February 28, 2026 13:14
@rustbot
Copy link
Collaborator

rustbot commented Feb 28, 2026

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.

@chenyukang
Copy link
Member Author

@bors r=JohnTitor

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 1, 2026

📌 Commit 3736458 has been approved by JohnTitor

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 1, 2026
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 1, 2026
…-closure-suggestion, r=JohnTitor

Suggest async block instead of async closure when possible

Fixes rust-lang#140265

r? @estebank
rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Rollup of 5 pull requests

Successful merges:

 - #152042 (Suggest async block instead of async closure when possible)
 - #152949 (Introduce --ci flag in tidy)
 - #152655 (Disable debug_assert_not_in_new_nodes for multiple threads)
 - #153209 (Clean up `QueryVTable::hash_result` into `hash_value_fn`)
 - #153229 (rustfmt: add test for field representing type builtin syntax)
rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Rollup of 5 pull requests

Successful merges:

 - #152042 (Suggest async block instead of async closure when possible)
 - #152949 (Introduce --ci flag in tidy)
 - #152655 (Disable debug_assert_not_in_new_nodes for multiple threads)
 - #153209 (Clean up `QueryVTable::hash_result` into `hash_value_fn`)
 - #153229 (rustfmt: add test for field representing type builtin syntax)
@rust-bors rust-bors bot merged commit c3969a7 into rust-lang:main Mar 1, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 1, 2026
rust-timer added a commit that referenced this pull request Mar 1, 2026
Rollup merge of #152042 - chenyukang:yukang-fix-140265-async-closure-suggestion, r=JohnTitor

Suggest async block instead of async closure when possible

Fixes #140265

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

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Poor suggestion for async || {} in place of async {}

5 participants