Skip to content

Commit 8af2884

Browse files
committed
Auto merge of rust-lang#6805 - matthiaskrgr:uca_nopub_6803, r=flip1995
upper_case_acronyms: don't warn on public items Fixes rust-lang#6803 changelog: upper_case_acronyms: ignore public items
2 parents d695bfc + 9dba6a9 commit 8af2884

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clippy_lints/src/upper_case_acronyms.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use if_chain::if_chain;
33
use itertools::Itertools;
4-
use rustc_ast::ast::{Item, ItemKind, Variant};
4+
use rustc_ast::ast::{Item, ItemKind, Variant, VisibilityKind};
55
use rustc_errors::Applicability;
66
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
77
use rustc_middle::lint::in_external_macro;
@@ -105,6 +105,8 @@ impl EarlyLintPass for UpperCaseAcronyms {
105105
it.kind,
106106
ItemKind::TyAlias(..) | ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Trait(..)
107107
);
108+
// do not lint public items
109+
if !matches!(it.vis.kind, VisibilityKind::Public);
108110
then {
109111
check_ident(cx, &it.ident, self.upper_case_acronyms_aggressive);
110112
}

tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs

+5
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ enum Flags {
2020
// `GccLlvmSomething`
2121
struct GCCLLVMSomething;
2222

23+
// don't warn on public items
24+
pub struct MIXEDCapital;
25+
26+
pub struct FULLCAPITAL;
27+
2328
fn main() {}

tests/ui/upper_case_acronyms.rs

+4
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ enum Flags {
2020
// `GccLlvmSomething`
2121
struct GCCLLVMSomething;
2222

23+
// public items must not be linted
24+
pub struct NOWARNINGHERE;
25+
pub struct ALSONoWarningHERE;
26+
2327
fn main() {}

0 commit comments

Comments
 (0)