Linux command
clippy 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Run clippy on project
cargo clippy
Run clippy and fix
cargo clippy --fix
Run clippy on all targets
cargo clippy --all-targets
Deny all warnings
cargo clippy -- -D warnings
Allow specific lint
cargo clippy -- -A clippy::needless_return
Show all available lints
cargo clippy --list
Run clippy in release mode
cargo clippy --release
说明
clippy is a collection of lints to catch common mistakes and improve Rust code. It provides hundreds of lints covering correctness, style, performance, complexity, and more. Clippy integrates with Cargo and analyzes code during compilation, providing actionable warnings. Lints range from simple style suggestions to detecting subtle bugs and performance issues. Many lints include automatic fixes that can be applied with `--fix`.
参数
- --fix
- Automatically apply lint suggestions.
- --all-targets
- Check all targets including tests and examples.
- --all-features
- Check with all features enabled.
- --release
- Check in release mode.
- --list
- List all available lints.
- -- -D _lint_
- Deny specific lint (treat as error).
- -- -W _lint_
- Warn on specific lint.
- -- -A _lint_
- Allow (ignore) specific lint.
- -- -F _lint_
- Forbid lint (cannot be overridden).
FAQ
What is the clippy command used for?
clippy is a collection of lints to catch common mistakes and improve Rust code. It provides hundreds of lints covering correctness, style, performance, complexity, and more. Clippy integrates with Cargo and analyzes code during compilation, providing actionable warnings. Lints range from simple style suggestions to detecting subtle bugs and performance issues. Many lints include automatic fixes that can be applied with `--fix`.
How do I run a basic clippy example?
Run `cargo clippy` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --fix do in clippy?
Automatically apply lint suggestions.