Clippy lints / Style
Clippy lint · Style · checked with Clippy 0.1.99
clippy::upper_case_acronyms: Checks for fully capitalized names and optionally names containing a capitalized acronym
What it meansChecks for fully capitalized names and optionally names containing a capitalized acronym. It is in the style group and warns by default.
Does it matter?
In CamelCase, acronyms count as one word. See naming conventions for more. By default, the lint only triggers on fully-capitalized names. You can use the upper-case-acronyms-aggressive: true config option to enable linting on all camel case names
Code that works but is not idiomatic Rust. Warns by default.
How to fix it
Clippy does not fix this one automatically (its suggestion may change behaviour, so it only shows it). Change the code by hand:
Flagged
struct HTTPResponse;
Write this instead
struct HttpResponse;
Turn it off, or on
Allow it where it does not fit your code, as narrowly as you can:
On one item
#[allow(clippy::upper_case_acronyms)]
fn my_function() { /* ... */ }Whole crate (Cargo.toml)
[lints.clippy]
upper_case_acronyms = "allow"One run
cargo clippy -- -A clippy::upper-case-acronymsThe [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.
Settings in clippy.toml
avoid-breaking-exported-api: Suppress lints whenever the suggested change would cause breakage for other crates.upper-case-acronyms-aggressive: Enables verbose mode. Triggers if there is more than one uppercase char next to each other
Clippy's own documentation
What it does
Checks for fully capitalized names and optionally names containing a capitalized acronym.
Why is this bad?
In CamelCase, acronyms count as one word. See naming conventions for more.
By default, the lint only triggers on fully-capitalized names.
You can use the upper-case-acronyms-aggressive: true config option to enable linting
on all camel case names
Known problems
When two acronyms are contiguous, the lint can’t tell where the first acronym ends and the second starts, so it suggests to lowercase all of the letters in the second acronym.
Example
struct HTTPResponse;
Use instead:
struct HttpResponse;
Configuration
-
avoid-breaking-exported-api: Suppress lints whenever the suggested change would cause breakage for other crates.(default:
true) -
upper-case-acronyms-aggressive: Enables verbose mode. Triggers if there is more than one uppercase char next to each other(default:
false)
From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.
Related lints
- needless_returnunneeded `return` statement
- new_without_defaultChecks for public types with a pub fn new() -> Self method and no implementation of Default
- len_zeroChecks for getting the length of something via .len() just to compare to zero, and suggests using .is_empty() where applicable
- unused_unitunneeded unit expression
- unusual_byte_groupingsWarns if hexadecimal or binary literals are not grouped by nibble or byte
- unwrap_or_defaultChecks for usages of the following functions with an argument that constructs a default value (e.g., Default::default or String::new): unwrap_or unwrap_or_else or_insert or_insert_with
- while_let_on_iteratorChecks for while let expressions on iterators
- write_literalThis lint warns about the use of literals as write!/writeln! args
- write_with_newlineThis lint warns when you use write!() with a format string that ends in a newline
All 847 Clippy lints · Rust compiler errors · Cargo.toml checker
Up next
Related lintclippy::needless_returnunneeded `return` statementRead it next →Did this answer your question?