@@ -19,21 +19,35 @@ You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the
1919| ` clippy::complexity ` | code that does something simple but in a complex way | ** warn** |
2020| ` clippy::perf ` | code that can be written to run faster | ** warn** |
2121| ` clippy::pedantic ` | lints which are rather strict or have occasional false positives | allow |
22+ | ` clippy::restriction ` | lints which prevent the use of language and library features[ ^ restrict ] | allow |
2223| ` clippy::nursery ` | new lints that are still under development | allow |
2324| ` clippy::cargo ` | lints for the cargo manifest | allow |
2425
2526More to come, please [ file an issue] ( https://github.com/rust-lang/rust-clippy/issues ) if you have ideas!
2627
27- The [ lint list] ( https://rust-lang.github.io/rust-clippy/master/index.html ) also contains "restriction lints", which are
28- for things which are usually not considered "bad", but may be useful to turn on in specific cases. These should be used
29- very selectively, if at all.
28+ The ` restriction ` category should, * emphatically* , not be enabled as a whole. The contained
29+ lints may lint against perfectly reasonable code, may not have an alternative suggestion,
30+ and may contradict any other lints (including other categories). Lints should be considered
31+ on a case-by-case basis before enabling.
32+
33+ [ ^ restrict ] : Some use cases for ` restriction ` lints include:
34+ - Strict coding styles (e.g. [ ` clippy::else_if_without_else ` ] ).
35+ - Additional restrictions on CI (e.g. [ ` clippy::todo ` ] ).
36+ - Preventing panicking in certain functions (e.g. [ ` clippy::unwrap_used ` ] ).
37+ - Running a lint only on a subset of code (e.g. ` #[forbid(clippy::float_arithmetic)] ` on a module).
38+
39+ [ `clippy::else_if_without_else` ] : https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
40+ [ `clippy::todo` ] : https://rust-lang.github.io/rust-clippy/master/index.html#todo
41+ [ `clippy::unwrap_used` ] : https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
42+
43+ ---
3044
3145Table of contents:
3246
33- * [ Usage instructions] ( #usage )
34- * [ Configuration] ( #configuration )
35- * [ Contributing] ( #contributing )
36- * [ License] ( #license )
47+ * [ Usage instructions] ( #usage )
48+ * [ Configuration] ( #configuration )
49+ * [ Contributing] ( #contributing )
50+ * [ License] ( #license )
3751
3852## Usage
3953
@@ -64,6 +78,7 @@ Once you have rustup and the latest stable release (at least Rust 1.29) installe
6478``` terminal
6579rustup component add clippy
6680```
81+
6782If it says that it can't find the ` clippy ` component, please run ` rustup self update ` .
6883
6984#### Step 3: Run Clippy
@@ -143,16 +158,16 @@ line. (You can swap `clippy::all` with the specific lint category you are target
143158
144159You can add options to your code to ` allow ` /` warn ` /` deny ` Clippy lints:
145160
146- * the whole set of ` Warn ` lints using the ` clippy ` lint group (` #![deny(clippy::all)] ` ).
161+ * the whole set of ` Warn ` lints using the ` clippy ` lint group (` #![deny(clippy::all)] ` ).
147162 Note that ` rustc ` has additional [ lint groups] ( https://doc.rust-lang.org/rustc/lints/groups.html ) .
148163
149- * all lints using both the ` clippy ` and ` clippy::pedantic ` lint groups (` #![deny(clippy::all)] ` ,
164+ * all lints using both the ` clippy ` and ` clippy::pedantic ` lint groups (` #![deny(clippy::all)] ` ,
150165 ` #![deny(clippy::pedantic)] ` ). Note that ` clippy::pedantic ` contains some very aggressive
151166 lints prone to false positives.
152167
153- * only some lints (` #![deny(clippy::single_match, clippy::box_vec)] ` , etc.)
168+ * only some lints (` #![deny(clippy::single_match, clippy::box_vec)] ` , etc.)
154169
155- * ` allow ` /` warn ` /` deny ` can be limited to a single function or module using ` #[allow(...)] ` , etc.
170+ * ` allow ` /` warn ` /` deny ` can be limited to a single function or module using ` #[allow(...)] ` , etc.
156171
157172Note: ` allow ` means to suppress the lint for your code. With ` warn ` the lint
158173will only emit a warning, while with ` deny ` the lint will emit an error, when
@@ -176,12 +191,14 @@ cargo clippy -- -W clippy::lint_name
176191
177192This also works with lint groups. For example, you
178193can run Clippy with warnings for all lints enabled:
194+
179195``` terminal
180196cargo clippy -- -W clippy::pedantic
181197```
182198
183199If you care only about a single lint, you can allow all others and then explicitly warn on
184200the lint(s) you are interested in:
201+
185202``` terminal
186203cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
187204```
0 commit comments