fix enum_variant_names depending lint depending on order
This commit is contained in:
parent
fa6fd8c346
commit
c51e2a0f75
@ -320,6 +320,11 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for var in def.variants {
|
||||||
|
check_enum_start(cx, item_name, var);
|
||||||
|
check_enum_end(cx, item_name, var);
|
||||||
|
}
|
||||||
|
|
||||||
let first = match def.variants.first() {
|
let first = match def.variants.first() {
|
||||||
Some(variant) => variant.ident.name.as_str(),
|
Some(variant) => variant.ident.name.as_str(),
|
||||||
None => return,
|
None => return,
|
||||||
@ -328,8 +333,6 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
|
|||||||
let mut post = pre.clone();
|
let mut post = pre.clone();
|
||||||
post.reverse();
|
post.reverse();
|
||||||
for var in def.variants {
|
for var in def.variants {
|
||||||
check_enum_start(cx, item_name, var);
|
|
||||||
check_enum_end(cx, item_name, var);
|
|
||||||
let name = var.ident.name.as_str();
|
let name = var.ident.name.as_str();
|
||||||
|
|
||||||
let variant_split = camel_case_split(name);
|
let variant_split = camel_case_split(name);
|
||||||
|
@ -204,4 +204,21 @@ enum Enum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod issue11494 {
|
||||||
|
// variant order should not affect lint
|
||||||
|
enum Data {
|
||||||
|
Valid,
|
||||||
|
Invalid,
|
||||||
|
DataDependent,
|
||||||
|
//~^ ERROR: variant name starts with the enum's name
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Datas {
|
||||||
|
DatasDependent,
|
||||||
|
//~^ ERROR: variant name starts with the enum's name
|
||||||
|
Valid,
|
||||||
|
Invalid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -158,5 +158,17 @@ LL | | }
|
|||||||
|
|
|
|
||||||
= help: remove the postfixes and use full paths to the variants instead of glob imports
|
= help: remove the postfixes and use full paths to the variants instead of glob imports
|
||||||
|
|
||||||
error: aborting due to 14 previous errors
|
error: variant name starts with the enum's name
|
||||||
|
--> $DIR/enum_variants.rs:212:9
|
||||||
|
|
|
||||||
|
LL | DataDependent,
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: variant name starts with the enum's name
|
||||||
|
--> $DIR/enum_variants.rs:217:9
|
||||||
|
|
|
||||||
|
LL | DatasDependent,
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 16 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user