Skip to content

Always emit async/await diagnostics last and group them when possible - #164942

Draft
estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:issue-90849
Draft

estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:issue-90849

Conversation

@estebank

@estebank estebank commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Delay diagnostics related to async-await in 2015 edition, and keep a list of their spans. If there are enough of them, emit a single diagnostic telling users that they are very likely in the wrong edition. Otherwise, emit the original diagnostics at the bottom of the diagnostic list.

error: `async`/`await` is not permitted in Rust 2015 edition
  --> $DIR/edition-deny-async-fns-2015.rs:3:1
   |
LL | async fn foo() {}
   | ^^^^^
...
LL | fn baz() { async fn foo() {} }
   |            ^^^^^
LL |
LL | async fn async_baz() {
   | ^^^^^
LL |     async fn bar() {}
   |     ^^^^^
...
LL |     async fn foo() {}
   |     ^^^^^
   |
   = note: ...and 4 other places
   = help: to use `async`/`await`, switch to Rust 2018 or later by passing `--edition 2024 to `rustc`
   = note: for more on editions, read <https://doc.rust-lang.org/edition-guide>

This is a maximalist potential approach to fix #90849.

Delay diagnostics related to async-await in 2015 edition, and keep a list of their spans. If there are enough of them, emit a single diagnostic telling users that they are very likely in the wrong edition. Otherwise, emit the original diagnostics at the bottom of the diagnostic list.

```
error: `async`/`await` is not permitted in Rust 2015 edition
  --> $DIR/edition-deny-async-fns-2015.rs:3:1
   |
LL | async fn foo() {}
   | ^^^^^
...
LL | fn baz() { async fn foo() {} }
   |            ^^^^^
LL |
LL | async fn async_baz() {
   | ^^^^^
LL |     async fn bar() {}
   |     ^^^^^
...
LL |     async fn foo() {}
   |     ^^^^^
   |
   = note: ...and 4 other places
   = help: to use `async`/`await`, switch to Rust 2018 or later by passing `--edition 2024 to `rustc`
   = note: for more on editions, read <https://doc.rust-lang.org/edition-guide>
```
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 26, 2026
@estebank

Copy link
Copy Markdown
Contributor Author

There are less invasive approaches that just emit_fatal when encountering either async or .await. We can also forego the new FxIndexSet and instead use the stash diagnostic tracking in-place.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] ui test:false 0.078
error[E0061]: this method takes 1 argument but 0 arguments were supplied
   --> src/tools/miri/src/bin/miri.rs:146:19
    |
146 |         tcx.dcx().emit_stashed_diagnostics();
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^-- argument #1 of type `&IndexSet<rustc_span::span_encoding::Span, FxBuildHasher>` is missing
    |
note: method defined here
   --> compiler/rustc_errors/src/lib.rs:711:12
    |
711 |     pub fn emit_stashed_diagnostics(&self, spans: &FxIndexSet<Span>) -> Option<ErrorGuaranteed> {
    |            ^^^^^^^^^^^^^^^^^^^^^^^^
help: provide the argument
    |
146 |         tcx.dcx().emit_stashed_diagnostics(/* &IndexSet<Span, FxBuildHasher> */);
    |                                            ++++++++++++++++++++++++++++++++++++

For more information about this error, try `rustc --explain E0061`.
[RUSTC-TIMING] miri test:false 0.256
error: could not compile `miri` (bin "miri") due to 1 previous error

@rust-bors

rust-bors Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #166004) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Use of .await in 2015 edition prints one error per use

3 participants