Stop triggering `non_camel_case_types` lint by underscores between letter & non-letter
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
enum MyNumber{
Float_3_14
}
Current output
warning: variant `Float_3_14` should have an upper camel case name
--> src\lib.rs:2:5
|
2 | Float_3_14
| ^^^^^^^^^^ help: convert the identifier to upper camel case: `Float3_14`
|
= note: `#[warn(non_camel_case_types)]` on by default
Desired output
No warning about camel case
Rationale and extra context
For languages that don't have an "upper case", the only way to separate parts is to use a real separator like an underscore.
If we only need separators between letters, or between letter & non-letter, then the boundary is clear even without underscores. But if we have underscores between non-letters, then the letter & non-letter would look weirdly close to each other without underscores compared to the underscore-separated non-letter parts.
From the doc:
The preferred style for these identifiers is to use “camel case”, such as
MyStruct, where the first letter should not be lowercase, and should not use underscores between letters. Underscores are allowed at the beginning and end of the identifier, as well as between non-letters (such asX86_64).
It seems that the rule between letter & non-letter isn't explicitly stated.
Other cases
No response
Rust Version
rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-pc-windows-msvc
release: 1.77.2
LLVM version: 17.0.6
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the non_camel_case_types example with Float_3_14, then trace the lint implementation and its existing tests from the non_camel_case_types documentation entry. Compare the current handling of letter/non-letter and non-letter/non-letter boundaries with the stated identifier rules; done means the example emits no camel-case warning and existing lint tests still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100