Clippy Explained How Lints Are Grouped and Configured
Clippy is the Rust linter with hundreds of lints in groups: correctness, style, perf, pedantic and more. Learn what each group means, how to configure them and how to adopt it in CI.

The compiler tells you what is wrong. Clippy tells you what is suspicious: a comparison that is always true, a loop that should be an iterator, a clone on a Copy type. It ships with Rust, and its lints are grouped so you can choose how strict to be. This post explains the groups and the rollout that works in practice. It pairs with lints in Cargo.toml.
Rust 1.90, Clippy bundled.
A first run
fn main() {
let v = vec![1, 2, 3];
if v.len() == 0 {
println!("empty");
}
let doubled: Vec<i32> = v.iter().map(|x| x * 2).collect();
println!("{}", doubled.len() > 0);
}cargo clippywarning: length comparison to zero
--> src/main.rs:3:8
|
3 | if v.len() == 0 {
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more idiomatic: `v.is_empty()`
|
= note: `#[warn(clippy::len_zero)]` on by defaultThe note names the lint and the group default. The second comparison produces the same warning. cargo clippy --fix applies both.
The groups
| Group | Default | Meaning |
|---|---|---|
correctness | deny | code that is almost certainly wrong |
suspicious | warn | code that is likely wrong |
style | warn | idiomatic spelling |
complexity | warn | simpler way to write it |
perf | warn | faster way to write it |
pedantic | allow | stricter, sometimes subjective |
restriction | allow | bans a language feature |
nursery | allow | new, may have false positives |
cargo | allow | Cargo.toml quality |
The default groups are the baseline; pick up pedantic as a second step.
Configure
[lints.clippy]
pedantic = { level = "warn", priority = -1 }
unwrap_used = "warn"
module_name_repetitions = "allow"The priority = -1 lets individual lints override the group. Thresholds live in clippy.toml, for example too-many-arguments-threshold = 6. Where to put the settings in a workspace is in lints in Cargo.toml.
Roll it out
- Run
cargo clippyand fix what the default groups report; the changes are usually small and mechanical. - Add
cargo clippy --all-targets -- -D warningsto CI. - Enable
pedanticas warnings, andallowthe lints that fight your style, with a one line reason. - Add selected
restrictionlints such asunwrap_usedfor library code.
Pin the toolchain, as in rust-toolchain.toml. A new Clippy release adds lints, and an unpinned CI can fail on code that did not change.
Allowing a lint
#[allow(clippy::too_many_arguments)] // mirrors the C API
fn open(a: u8, b: u8, c: u8, d: u8, e: u8, f: u8, g: u8, h: u8) {}Scope it narrowly and say why. A crate-wide #![allow(clippy::all)] silences everything, including the lints that find bugs.
Where Clippy is wrong
Lints have false positives, particularly in nursery and in macro-generated code. File an issue if you find one. Clippy cannot find logic errors, and it does not replace tests. The lint list with explanations is at rust-lang.github.io/rust-clippy.


