rust-lang / rust-lang/rust-clippy
`struct_field_names` not triggered when 2 or less fields
Open
@alexis-langlet is already working on this.
Since Jan 4, 2024.
C-bug
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
As mentioned in #12035, struct_field_names lint is only triggered when struct contains more than 3 fields.
It should be triggered no matter the fields' number.
Lint Name
struct_field_names
Reproducer
I tried this code:
#![warn(clippy::pedantic)]
struct A {
a_group: String,
a_location: String,
}
struct_field_names
I expected to see this happen: warning: field name starts with the struct's name
Instead, this happened: no warning about it
Version
rustc 1.76.0-nightly (87e1447aa 2023-11-30)
binary: rustc
commit-hash: 87e1447aadaa2899ff6ccabe1fa669eb50fb60a1
commit-date: 2023-11-30
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
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.
Assessment
This issue has not been assessed yet.