Skip to content

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Oct 12, 2025

This changes underscore from being a punctuation character to a keyword. This is intended to help better align with proc-macros, which treat it as an Ident.

Note one unusual rule is inline assembly ParamName which is IDENTIFIER_OR_KEYWORD. From what I can tell, it does accept _, but the fmt template does not. Templates are not specified in great detail in the std docs, and don't touch on this fact.

Closes #1236
Closes #2020

cc @petrochenkov @mattheww

This changes underscore from being a punctuation character to a keyword.
This is intended to help better align with proc-macros, which treat it
as an [`Ident`](https://doc.rust-lang.org/proc_macro/struct.Ident.html).

Note one unusual rule is inline assembly `ParamName` which is
`IDENTIFIER_OR_KEYWORD`. From what I can tell, it does accept `_`, but
the fmt template does not. Templates are not specified in great detail
in the std docs, and don't touch on this fact.

Closes rust-lang#1236
Closes rust-lang#2020
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Further cases where lone underscore isn't covered Grammar for "identifier or keyword" seems wrong

2 participants