mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-16 09:48:08 +00:00
round 3
This commit is contained in:
parent
a976401171
commit
af98a7ce52
1 changed files with 12 additions and 14 deletions
|
@ -135,20 +135,18 @@ impl EarlyLintPass for EnumVariantNames {
|
||||||
let item_name = item.ident.name.as_str();
|
let item_name = item.ident.name.as_str();
|
||||||
let item_name_chars = item_name.chars().count();
|
let item_name_chars = item_name.chars().count();
|
||||||
let item_camel = to_camel_case(&item_name);
|
let item_camel = to_camel_case(&item_name);
|
||||||
if item.vis == Visibility::Public {
|
if item.vis == Visibility::Public && !in_macro(cx, item.span) {
|
||||||
if !in_macro(cx, item.span) {
|
if let Some(mod_camel) = self.modules.last() {
|
||||||
if let Some(mod_camel) = self.modules.last() {
|
// constants don't have surrounding modules
|
||||||
// constants don't have surrounding modules
|
if !mod_camel.is_empty() {
|
||||||
if !mod_camel.is_empty() {
|
let matching = partial_match(mod_camel, &item_camel);
|
||||||
let matching = partial_match(mod_camel, &item_camel);
|
let rmatching = partial_rmatch(mod_camel, &item_camel);
|
||||||
let rmatching = partial_rmatch(mod_camel, &item_camel);
|
let nchars = mod_camel.chars().count();
|
||||||
let nchars = mod_camel.chars().count();
|
if matching == nchars {
|
||||||
if matching == nchars {
|
span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) starts with its containing module's name ({})", item_camel, mod_camel));
|
||||||
span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) starts with its containing module's name ({})", item_camel, mod_camel));
|
}
|
||||||
}
|
if rmatching == nchars {
|
||||||
if rmatching == nchars {
|
span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) ends with its containing module's name ({})", item_camel, mod_camel));
|
||||||
span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) ends with its containing module's name ({})", item_camel, mod_camel));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue