Skip to content

Bad parse error on many token sequences #136100

Open
@ionicmc-rs

Description

@ionicmc-rs

Code

// This is the only one i've found for now
async const FOO: () = ();

Current output

error: expected one of `extern`, `fn`, `gen`, `safe`, or `unsafe`, found keyword `const`
 --> src/main.rs:8:7
  |
8 | async const FOO: () = ();
  | ------^^^^^
  | |     |
  | |     expected one of `extern`, `fn`, `gen`, `safe`, or `unsafe`
  | help: `const` must come before `async`: `const async`
  |
  = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`

Desired output

error: expected one of `fn`, `gen`, `unsafe`, ..., found keyword `const`
--> src/main.rs:8:7
   |
 8 | async const FOO: () = ();
   | ------^^^^^
   | |     |
   | |     unexpected item
   = note: constants cannot be `async`

Rationale and extra context

this is meant to be a more general version of #134580

as opposed to #134580, however, this does not apply to const async, which is better

Other cases

TODO: add more cases

Rust Version

$ rustc --version --verbose
rustc 1.86.0-nightly (48a426eca 2025-01-12)
binary: rustc
commit-hash: 48a426eca9df23b24b3559e545cf88dee61d4de9
commit-date: 2025-01-12
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions