Skip to content

Commit

Permalink
upper_case_acronyms: don't warn on public items
Browse files Browse the repository at this point in the history
Fixes #6803

changelog: upper_case_acronyms: ignore public items
  • Loading branch information
matthiaskrgr committed Feb 26, 2021
1 parent 6343446 commit 9dba6a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clippy_lints/src/upper_case_acronyms.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
4 changes: 4 additions & 0 deletions tests/ui/upper_case_acronyms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 9dba6a9

Please sign in to comment.