@@ -194,21 +194,25 @@ impl EarlyLintPass for EnumVariantNames {
194
194
let item_name = item. ident . name . as_str ( ) ;
195
195
let item_name_chars = item_name. chars ( ) . count ( ) ;
196
196
let item_camel = to_camel_case ( & item_name) ;
197
- if item . vis == Visibility :: Public && !in_macro ( cx, item. span ) {
197
+ if !in_macro ( cx, item. span ) {
198
198
if let Some ( & ( ref mod_name, ref mod_camel) ) = self . modules . last ( ) {
199
199
// constants don't have surrounding modules
200
200
if !mod_camel. is_empty ( ) {
201
201
if mod_name == & item_name {
202
- span_lint ( cx, MODULE_INCEPTION , item. span , "item has the same name as its containing module" ) ;
202
+ if let ItemKind :: Mod ( ..) = item. node {
203
+ span_lint ( cx, MODULE_INCEPTION , item. span , "module has the same name as its containing module" ) ;
204
+ }
203
205
}
204
- let matching = partial_match ( mod_camel, & item_camel) ;
205
- let rmatching = partial_rmatch ( mod_camel, & item_camel) ;
206
- let nchars = mod_camel. chars ( ) . count ( ) ;
207
- if matching == nchars {
208
- span_lint ( cx, STUTTER , item. span , & format ! ( "Item name ({}) starts with its containing module's name ({})" , item_camel, mod_camel) ) ;
209
- }
210
- if rmatching == nchars {
211
- span_lint ( cx, STUTTER , item. span , & format ! ( "Item name ({}) ends with its containing module's name ({})" , item_camel, mod_camel) ) ;
206
+ if item. vis == Visibility :: Public {
207
+ let matching = partial_match ( mod_camel, & item_camel) ;
208
+ let rmatching = partial_rmatch ( mod_camel, & item_camel) ;
209
+ let nchars = mod_camel. chars ( ) . count ( ) ;
210
+ if matching == nchars {
211
+ span_lint ( cx, STUTTER , item. span , "item name starts with its containing module's name" ) ;
212
+ }
213
+ if rmatching == nchars {
214
+ span_lint ( cx, STUTTER , item. span , "item name ends with its containing module's name" ) ;
215
+ }
212
216
}
213
217
}
214
218
}
0 commit comments