mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Merge pull request #2127 from rust-lang-nursery/enum_variant_names_fp
Don't lint accidental "prefixes" on enum variants
This commit is contained in:
commit
f0aa2c1587
2 changed files with 16 additions and 1 deletions
|
@ -159,7 +159,8 @@ fn check_variant(
|
|||
}
|
||||
for var in &def.variants {
|
||||
let name = var2str(var);
|
||||
if partial_match(item_name, &name) == item_name_chars {
|
||||
if partial_match(item_name, &name) == item_name_chars &&
|
||||
name.chars().nth(item_name_chars).map_or(false, |c| !c.is_lowercase()) {
|
||||
span_lint(cx, lint, var.span, "Variant name starts with the enum's name");
|
||||
}
|
||||
if partial_rmatch(item_name, &name) == item_name_chars {
|
||||
|
|
|
@ -102,4 +102,18 @@ mod allowed {
|
|||
}
|
||||
}
|
||||
|
||||
// should not lint
|
||||
enum Pat {
|
||||
Foo,
|
||||
Bar,
|
||||
Path,
|
||||
}
|
||||
|
||||
// should not lint
|
||||
enum N {
|
||||
Pos,
|
||||
Neg,
|
||||
Float,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Reference in a new issue