cargo-clippy
A collection of lints to catch common mistakes and improve your Rust code.
TLDR
Run checks over the code in the current directory
Require that Cargo.lock is up to date
Run checks on all packages in the workspace
Run checks for a package
Run checks for a lint group (see
Treat warnings as errors
Run checks and ignore warnings
Apply Clippy suggestions automatically
Help
Checks a package to catch common mistakes and improve your Rust code.
Usage:
cargo clippy [options] [--] [
Common options:
--no-deps Run Clippy only on the given crate, without linting the dependencies
--fix Automatically apply lint suggestions. This flag implies `--no-deps` and `--all-targets`
-h, --help Print this message
-V, --version Print version info and exit
--explain LINT Print the documentation for a given lint
For the other options see `cargo check --help`.
To allow or deny a lint from the command line you can use `cargo clippy --`
with:
-W --warn OPT Set lint warnings
-A --allow OPT Set lint allowed
-D --deny OPT Set lint denied
-F --forbid OPT Set lint forbidden
You can use tool lints to allow or deny lints from your code, e.g.:
#[allow(clippy::needless_lifetimes)]