Don't lint accidental "prefixes" on enum variants

This commit is contained in:
Oliver Schneider 2017-10-10 12:15:55 +02:00
parent b62b1b68ed
commit af6e2a1e4e
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9
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() {}