Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upper_case_acronyms: don't warn on public items #6805

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}