-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
enum_variant_names false positive when first word has common prefix as part of word #8090
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
Comments
Huh 🤔 I can take a look on this @rustbot claim |
bors
added a commit
that referenced
this issue
Dec 27, 2021
Fix `enum_variants` FP on prefixes that are not camel-case closes #8090 Fix FP on `enum_variants` when prefixes are only a substring of a camel-case word. Also adds some util helpers on `str_utils` to help parsing camel-case strings. This changes how the lint behaves: 1. previously if the Prefix is only a length of 1, it's going to get ignored, i.e. these were previously ignored and now is warned ```rust enum Foo { cFoo, cBar, cBaz, } enum Something { CCall, CCreate, CCryogenize, } ``` 2. non-ascii characters that doesn't have casing will not be split, ```rust enum NonCaps { Prefix的, PrefixTea, PrefixCake, } ``` will be considered as `Prefix的`, `Prefix`, `Prefix`, so this won't lint as opposed to fired previously. changelog: [`enum_variant_names`] Fix FP when first prefix are only a substring of a camel-case word.
bors
added a commit
that referenced
this issue
Dec 27, 2021
Fix `enum_variants` FP on prefixes that are not camel-case closes #8090 Fix FP on `enum_variants` when prefixes are only a substring of a camel-case word. Also adds some util helpers on `str_utils` to help parsing camel-case strings. This changes how the lint behaves: 1. previously if the Prefix is only a length of 1, it's going to get ignored, i.e. these were previously ignored and now is warned ```rust enum Foo { cFoo, cBar, cBaz, } enum Something { CCall, CCreate, CCryogenize, } ``` 2. non-ascii characters that doesn't have casing will not be split, ```rust enum NonCaps { PrefixXXX, PrefixTea, PrefixCake, } ``` will be considered as `PrefixXXX`, `Prefix`, `Prefix`, so this won't lint as opposed to fired previously. changelog: [`enum_variant_names`] Fix FP when first prefix are only a substring of a camel-case word. --- (Edited by `@xFrednet` removed some non ascii characters)
bors
added a commit
that referenced
this issue
Dec 27, 2021
Fix `enum_variants` FP on prefixes that are not camel-case closes #8090 Fix FP on `enum_variants` when prefixes are only a substring of a camel-case word. Also adds some util helpers on `str_utils` to help parsing camel-case strings. This changes how the lint behaves: 1. previously if the Prefix is only a length of 1, it's going to get ignored, i.e. these were previously ignored and now is warned ```rust enum Foo { cFoo, cBar, cBaz, } enum Something { CCall, CCreate, CCryogenize, } ``` 2. non-ascii characters that doesn't have casing will not be split, ```rust enum NonCaps { PrefixXXX, PrefixTea, PrefixCake, } ``` will be considered as `PrefixXXX`, `Prefix`, `Prefix`, so this won't lint as opposed to fired previously. changelog: [`enum_variant_names`] Fix FP when first prefix are only a substring of a camel-case word. --- (Edited by `@xFrednet` removed some non ascii characters)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The lint warns if all variants have the same prefix word. If the first variant has the prefix word at the start of its first word, it wrongly triggers the lint even if the first word is longer than the prefix word. If this variant is not the first variant, the warning is not triggered.
Lint Name
enum_variant_names
Reproducer
I tried this code:
I saw this happen:
I expected no warning.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: