struct_field_names
triggers when the field name *is* the struct name
#13857
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
I'm not sure if this is an actual false positive (looks like changing
>=
to>
here might stop it from firing) or it's just not clear to me (even after reading the lint description) why it thinks this is bad.The lint description says it checks for prefixes / suffixes, and suggests I delete them. That makes sense to me.
But if the field name is the struct name I can't delete the entire name, I'd have to come up with a different one. I could see the point in suggesting that I use a newtype if I had no other fields, but the lint actually won't fire unless I do have other fields, so that doesn't apply either.
That leaves "come up with a different name". If there is value to that, I'd appreciate the lint description explaining it.
Issue #12922 is somewhat related (not just because it's the same lint): the first example there (
app
instruct App
) would also be allowed if this was changed.Lint Name
struct_field_names
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
Either no lint or a better explanation of why this is bad and what I should do instead.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: