Skip to content

Bad parse error on many token sequences #136100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ionicmc-rs opened this issue Jan 26, 2025 · 1 comment
Open

Bad parse error on many token sequences #136100

ionicmc-rs opened this issue Jan 26, 2025 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ionicmc-rs
Copy link
Contributor

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

@ionicmc-rs ionicmc-rs added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 26, 2025
@ionicmc-rs
Copy link
Contributor Author

Just wanted to clarify many includes the other issue

@fmease fmease added the A-parser Area: The parsing of Rust source code to an AST label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants