Skip to content
Latchkey

cargo clippy: Usage, Options & Common CI Errors

Lint Rust for correctness, style, and performance.

cargo clippy is an official lint tool that catches common mistakes and non-idiomatic code. In CI you typically promote warnings to errors so a lint regression fails the build.

What it does

Runs the compiler with Clippy lint passes enabled, emitting suggestions across correctness, style, complexity, and performance categories. Lint levels are controlled with -W, -A, and -D after a -- separator.

Common usage

Terminal
cargo clippy                                  # lint the package
cargo clippy --workspace --all-targets        # lint everything
cargo clippy --fix                            # auto-apply fixes
cargo clippy -- -D warnings                   # fail on any warning
cargo clippy -- -A clippy::too_many_arguments # allow one lint

Common CI error: clippy component missing

On a minimal toolchain CI fails with "error: no such command: clippy" or "error: the clippy component is not installed." Fix: install it with rustup component add clippy (the dtolnay/rust-toolchain action accepts components: clippy).

Options

FlagEffect
--fixApply machine-applicable fixes
--all-targetsLint tests and examples too
-- -D warningsTreat warnings as errors
-- -W clippy::pedanticEnable the pedantic group

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →