LinuxCommandLibrary

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

$ cargo clippy
copy


Require that Cargo.lock is up to date
$ cargo clippy --locked
copy


Run checks on all packages in the workspace
$ cargo clippy --workspace
copy


Run checks for a package
$ cargo clippy --package [package]
copy


Treat warnings as errors
$ cargo clippy -- --deny warnings
copy


Run checks and ignore warnings
$ cargo clippy -- --allow warnings
copy


Apply Clippy suggestions automatically
$ cargo clippy --fix
copy

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)] 

Copied to clipboard