← 返回命令列表

Linux command

cargo-clippy 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Run clippy lints

cargo clippy

Lint all targets

cargo clippy --all-targets

Lint with all features

cargo clippy --all-features

Fail on warnings (for CI)

cargo clippy -- -D warnings

Allow specific lint

cargo clippy -- -A clippy::[lint_name]

Warn on specific lint

cargo clippy -- -W clippy::[lint_name]

Automatically fix issues

cargo clippy --fix

Full CI check

cargo clippy --all-targets --all-features -- -D warnings

说明

cargo clippy is the Rust linter that catches common mistakes and suggests improvements. Part of the Rust toolchain via rustup. Runs the default clippy::all lint group.

参数

--all-targets
Lint all targets (lib, bin, tests, examples, benches)
--all-features
Enable all available features
--features _features_
Enable specified features
--release
Lint in release mode
--workspace
Lint all workspace members
--fix
Automatically apply suggested fixes
-- -A _lint_
Allow specified lint
-- -W _lint_
Warn on specified lint
-- -D _lint_
Deny specified lint (treat as error)

FAQ

What is the cargo-clippy command used for?

cargo clippy is the Rust linter that catches common mistakes and suggests improvements. Part of the Rust toolchain via rustup. Runs the default clippy::all lint group.

How do I run a basic cargo-clippy example?

Run `cargo clippy` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --all-targets do in cargo-clippy?

Lint all targets (lib, bin, tests, examples, benches)