rust-lang /rust-clippy
A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
★ 13,662⑂ 2,287👁 75⑃ 9,197● 8,723▤ 0
+6
日增长
13,662
stars
2,287
forks
75
watchers
9,197
prs
8,723
issues
0
releases
README
Clippy
A collection of lints to catch common mistakes and improve your Rust code.
There are over 800 lints included in this crate!
Lints are divided into categories, each with a default lint level.
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
| Category | Description | Default level |
|-----------------------|-------------------------------------------------------------------------------------|---------------|
| clippy::all | all lints that are on by default (correctness, suspicious, style, complexity, perf) | warn/deny |
| clippy::correctness | code that is outright wrong or useless | deny |
| clippy::suspicious | code that is most likely wrong or useless | warn |
| clippy::style | code that should be written in a more idiomatic way | warn |
| clippy::complexity | code that does something simple but in a complex way | warn |
| clippy::perf | code that can be written to run faster | warn |
| clippy::pedantic | lints which are rather strict or have occasional false positives | allow |
| clippy::restriction | lints which prevent the use of language and library features[^restrict] | allow |
| clippy::nursery | new lints that are still under development | allow |
| clippy::cargo | lints for the cargo manifest | allow |
More to come, please file an issue if you have ideas!
The restriction category should, emphatically, not be enabled as a whole. The contained
lints may lint against perfectly reasonable code, may not have an alternative suggestion,
and may contradict any other lints (including other categories). Lints should be considered
on a case-by-case basis before enabling.
[^restrict]: Some use cases for restriction lints include:
- Strict coding styles (e.g. [clippy::else_if_without_else]).
- Additional restrictions on CI (e.g. [clippy::todo]).
- Preventing panicking in certain functions (e.g. [clippy::unwrap_used]).
- Running a lint only on a subset of code (e.g. [forbid(clippy::float_arithmetic)] on a module).
[clippy::else_if_without_else]: https://clippy.rust-lang.org/main/index.htmlelse_if_without_else
[clippy::todo]: https://clippy.rust-lang.org/main/index.htmltodo
[clippy::unwrap_used]: https://clippy.rust-lang.org/main/index.htmlunwrap_used
---
Table of contents:
Usage instructions
Configuration
Contributing
License
Usage
Below are instructions on how to use Clippy as a cargo subcommand,
in projects that do not use cargo, or in Travis CI.
As a cargo sTop issues
#8045non_send_fields_in_send_ty seems to be misguided33 comments · 2021-11-30#6680[Tracking issue] Rearrange location of some of the existing lints30 comments · 2021-02-05#3770if_same_then_else Should not warn for `else if` blocks.30 comments · 2019-02-16#4894New lint: Use `Into`/`TryInto` in bounds as opposed to `From`/`TryFrom`29 comments · 2019-12-10#1689Warn about trait bounds on struct and enum type parameters26 comments · 2017-04-22#9231Have a lint against usize-to-u64 casts (or, against *all* integer casts)25 comments · 2022-07-23#4774New lint: `_.as_ptr() as *mut _` is Undefined Behavior25 comments · 2019-11-05#2394Politely mention that `Box<&T>` is almost the most useless type you can have25 comments · 2018-01-23
Discussions
#17858clippy::casting group0 comments · 2026-10-08#17367Discussion for `iter_nth_zero`: would it improve readablility for most cases? should it be enabled by default?1 comments · 2026-07-06#17300The iter_with_drain lint seems too strict1 comments · 2026-06-24#17267len_zero: split into positive and negative?0 comments · 2026-06-19#17040Is this really better?3 comments · 2026-05-19#17021How do I tell clippy to ignore code generated by a macro?1 comments · 2026-05-16#16994What is this MSRV lint telling me?1 comments · 2026-05-11#16944Is `clippy -- -W help` a reliable way to detect which lints are enforced?1 comments · 2026-04-30