@@ -99,21 +99,21 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident, be_aggressive: bool) {
99
99
100
100
impl EarlyLintPass for UpperCaseAcronyms {
101
101
fn check_item ( & mut self , cx : & EarlyContext < ' _ > , it : & Item ) {
102
- if_chain ! {
103
- if !in_external_macro( cx. sess( ) , it. span) ;
102
+ // do not lint public items or in macros
103
+ if !in_external_macro ( cx. sess ( ) , it. span ) && ! matches ! ( it . vis . kind , VisibilityKind :: Public ) {
104
104
if matches ! (
105
105
it. kind,
106
- ItemKind :: TyAlias ( ..) | ItemKind :: Enum ( ..) | ItemKind :: Struct ( ..) | ItemKind :: Trait ( ..)
107
- ) ;
108
- // do not lint public items
109
- if !matches!( it. vis. kind, VisibilityKind :: Public ) ;
110
- then {
106
+ ItemKind :: TyAlias ( ..) | ItemKind :: Struct ( ..) | ItemKind :: Trait ( ..)
107
+ ) {
111
108
check_ident ( cx, & it. ident , self . upper_case_acronyms_aggressive ) ;
109
+ } else if let ItemKind :: Enum ( ref enumdef, _) = it. kind {
110
+ // check enum variants seperately because again we only want to lint on private enums and
111
+ // the fn check_variant does not know about the vis of the enum of its variants
112
+ & enumdef
113
+ . variants
114
+ . iter ( )
115
+ . for_each ( |variant| check_ident ( cx, & variant. ident , self . upper_case_acronyms_aggressive ) ) ;
112
116
}
113
117
}
114
118
}
115
-
116
- fn check_variant ( & mut self , cx : & EarlyContext < ' _ > , v : & Variant ) {
117
- check_ident ( cx, & v. ident , self . upper_case_acronyms_aggressive ) ;
118
- }
119
119
}
0 commit comments