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
