Skip to content
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

Rust: Attempt to lex constant idents #741

Merged

Conversation

CosmicHorrorDev
Copy link
Contributor

@CosmicHorrorDev CosmicHorrorDev commented Jan 29, 2023

From the Rust style guide:

https://doc.rust-lang.org/beta/style-guide/advice.html#names

  • Constants (consts and immutable statics) shall be SCREAMING_SNAKE_CASE.

While giving that casing to nothing else. This means that we can attempt to lex constant idents by detecting if they are SCREAMING_SNAKE_CASE. I opted for at least 2 uppercase letters since I have seen generics use names like T0 and T1 (albeit rarely). The word boundaries (\b) are used to avoid lexing parts of idents that just so happen to have at least two consecutive uppercase letters like BTreeSet

@alecthomas alecthomas merged commit 55b0e59 into alecthomas:master Jan 29, 2023
@alecthomas
Copy link
Owner

Thanks again!

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.

None yet

2 participants