mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Don't lint accidental "prefixes" on enum variants
This commit is contained in:
parent
b62b1b68ed
commit
af6e2a1e4e
@ -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 New Issue
Block a user