about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-02-26 21:22:30 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2021-02-26 21:31:34 +0100
commit9dba6a9fdeefba74167953fc14610faec387a9c9 (patch)
tree4abc0a154f75fe218e46a5e4f72d86e292b5159b
parent6343446b892a04601e8c248726c4c22dfea64d63 (diff)
downloadrust-9dba6a9fdeefba74167953fc14610faec387a9c9.tar.gz
rust-9dba6a9fdeefba74167953fc14610faec387a9c9.zip
upper_case_acronyms: don't warn on public items
Fixes #6803

changelog: upper_case_acronyms: ignore public items
-rw-r--r--clippy_lints/src/upper_case_acronyms.rs4
-rw-r--r--tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs5
-rw-r--r--tests/ui/upper_case_acronyms.rs4
3 files changed, 12 insertions, 1 deletions
diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs
index 0470e1dbbb8..fea3abaec93 100644
--- a/clippy_lints/src/upper_case_acronyms.rs
+++ b/clippy_lints/src/upper_case_acronyms.rs
@@ -1,7 +1,7 @@
 use crate::utils::span_lint_and_sugg;
 use if_chain::if_chain;
 use itertools::Itertools;
-use rustc_ast::ast::{Item, ItemKind, Variant};
+use rustc_ast::ast::{Item, ItemKind, Variant, VisibilityKind};
 use rustc_errors::Applicability;
 use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
 use rustc_middle::lint::in_external_macro;
@@ -105,6 +105,8 @@ impl EarlyLintPass for UpperCaseAcronyms {
                 it.kind,
                 ItemKind::TyAlias(..) | ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Trait(..)
             );
+            // do not lint public items
+            if !matches!(it.vis.kind, VisibilityKind::Public);
             then {
                 check_ident(cx, &it.ident, self.upper_case_acronyms_aggressive);
             }
diff --git a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs
index fdf8905f812..5d54e083ef0 100644
--- a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs
+++ b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs
@@ -19,4 +19,9 @@ enum Flags {
 struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
                          // `GccLlvmSomething`
 
+// don't warn on public items
+pub struct MIXEDCapital;
+
+pub struct FULLCAPITAL;
+
 fn main() {}
diff --git a/tests/ui/upper_case_acronyms.rs b/tests/ui/upper_case_acronyms.rs
index fdf8905f812..eea125500a2 100644
--- a/tests/ui/upper_case_acronyms.rs
+++ b/tests/ui/upper_case_acronyms.rs
@@ -19,4 +19,8 @@ enum Flags {
 struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
                          // `GccLlvmSomething`
 
+// public items must not be linted
+pub struct NOWARNINGHERE;
+pub struct ALSONoWarningHERE;
+
 fn main() {}