Skip to content

Commit 4e19d40

Browse files
committed
upper_case_acronyms: only lint enum variants if the enum is not public
1 parent 6f2a6fe commit 4e19d40

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

clippy_lints/src/upper_case_acronyms.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,21 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident, be_aggressive: bool) {
9999

100100
impl EarlyLintPass for UpperCaseAcronyms {
101101
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) {
104104
if matches!(
105105
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+
) {
111108
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));
112116
}
113117
}
114118
}
115-
116-
fn check_variant(&mut self, cx: &EarlyContext<'_>, v: &Variant) {
117-
check_ident(cx, &v.ident, self.upper_case_acronyms_aggressive);
118-
}
119119
}

0 commit comments

Comments
 (0)