From 7253ce73bb17d1dc872f66b5ed9a02ea68ca0060 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 10 Jun 2016 16:14:36 +0200 Subject: [PATCH] only lint public stutter namings --- clippy_lints/src/enum_variants.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 5ef507e2786..d03afde0132 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -135,18 +135,20 @@ fn check_item(&mut self, cx: &EarlyContext, item: &Item) { let item_name = item.ident.name.as_str(); let item_name_chars = item_name.chars().count(); let item_camel = to_camel_case(&item_name); - if !in_macro(cx, item.span) { - if let Some(mod_camel) = self.modules.last() { - // constants don't have surrounding modules - if !mod_camel.is_empty() { - let matching = partial_match(mod_camel, &item_camel); - let rmatching = partial_rmatch(mod_camel, &item_camel); - let nchars = mod_camel.chars().count(); - 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)); - } - 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)); + if item.vis == Visibility::Public { + if !in_macro(cx, item.span) { + if let Some(mod_camel) = self.modules.last() { + // constants don't have surrounding modules + if !mod_camel.is_empty() { + let matching = partial_match(mod_camel, &item_camel); + let rmatching = partial_rmatch(mod_camel, &item_camel); + let nchars = mod_camel.chars().count(); + 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)); + } + 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)); + } } } } -- 2.44.0