liveBook · Manning

Cargo clippy

As explained in Code Like a Pro in Rust

rust-clippy is a Rust linter that detects common mistakes and recommends idiomatic improvements.

cargo clippy runs Rust’s Clippy linter through Cargo to detect common problems, enforce idiomatic patterns, and suggest precise code improvements. section 3.4

Use Clippy as part of an iterative quality workflow:

  • Install it with rustup component add clippy. section 3.4.1
  • Run cargo clippy on the project to receive compiler-style diagnostics and suggestions. section 3.4.1
  • Apply precise automatic fixes with cargo clippy --fix -Z unstable-options; the fix workflow is nightly-only at the stated toolchain era. section 3.4.4
  • Run Clippy after build, test, and formatting in CI, optionally checking all targets and features and promoting warnings to errors. section 3.4.5

Allow an intentional complexity exception

Use #[allow(clippy::too_many_arguments)] immediately before a function when its argument count is intentional. Configure the project-wide threshold in .clippy.toml with too-many-arguments-threshold = 10. section 3.4.3

$ cargo clippy                                                #1
...
$ cargo clippy -- -D warnings                                 #2
...
$ cargo clippy --all-targets --all-features -- -D warnings    #3
...

Compare basic linting with warning enforcement and all-target, all-feature CI checks. section 3.4.5

How Code Like a Pro in Rust covers it

How deep it goes
Explains installation, execution, configuration, automatic fixes, and CI integration, but does not detail individual lint implementations.
Examples
Uses Cargo commands, compiler-style diagnostics, GitHub Actions configuration, and too_many_arguments exceptions.
What it assumes
Assumes familiarity with Rust projects and Cargo while teaching Clippy installation and basic invocation.
What you can do after
Operate/configure it locally and in CI, apply selected fixes, and manage intentional lint exceptions.
How it connects
Connects Clippy with Cargo, rustup, rustfmt, stable and nightly toolchains, and CI/CD workflows.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Code Like a Pro in Rust. The section links point to the parts of the book it draws on.