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:
Oliver Schneider 2017-10-11 13:16:59 +02:00 committed by GitHub
commit f0aa2c1587
2 changed files with 16 additions and 1 deletions

View file

@ -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 {

View file

@ -102,4 +102,18 @@ mod allowed {
}
}
// should not lint
enum Pat {
Foo,
Bar,
Path,
}
// should not lint
enum N {
Pos,
Neg,
Float,
}
fn main() {}