Skip to content

Conversation

@ehuss
Copy link
Contributor

@ehuss ehuss commented Dec 20, 2025

This fixes the order of several of the lexical rules given our interpretation of "first match wins" for alternation.

This fixes the order of PUNCTUATION given our interpretation of
"first match wins" for alternation.

This moves the longer strings to the start to prevent any prefix
matching from happening (for example `.` instead of `...`).
This fixes the order of LIFETIME_TOKEN (and LIFETIME_OR_LABEL) given our
interpretation of "first match wins" for alternation.

This moves RAW_LIFETIME to the start, otherwise a raw lifetime `'r#foo`
would be interpreted as LIFETIME_TOKEN (`'r`) PUNCTUATION (`#`)
IDENTIFIER_OR_KEYWORD (`foo`).
This fixes the order of FLOAT_LITERAL given our interpretation of "first
match wins" for alternation. This moves the first rule (which matches
things like `3.`) to the end so that other two rules have a chance to
match something.

Otherwise, input like `3.14` would be FLOAT_LITERAL (3.) INTEGER_LITERAL
(14).
This fixes the order of INTEGER_LITERAL given our interpretation of
"first match wins" for alternation. This moves DEC_LITERAL to the end of
the list. Otherwise, an input of `0b1` would be interpreted as
INTEGER_LITERAL (0) IDENTIFIER_OR_KEYWORD (b) INTEGER_LITERAL (1)
instead of INTEGER_LITERAL (0b1).
With our interpretation of "first match wins" with alternation, this
fixes a problem where INTEGER_LITERAL was incorrectly in front of
FLOAT_LITERAL.

Otherwise, an input of `1.2` would be interpreted as `INTEGER_LITERAL`,
`PUNCTUATION`, `INTEGER_LITERAL` instead of `FLOAT_LITERAL`.
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Dec 20, 2025
@traviscross traviscross added this pull request to the merge queue Dec 22, 2025
Merged via the queue into rust-lang:master with commit 68bdfd1 Dec 22, 2025
5 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants