You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-11Lines changed: 21 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -19,21 +19,28 @@ You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the
19
19
|`clippy::complexity`| code that does something simple but in a complex way |**warn**|
20
20
|`clippy::perf`| code that can be written to run faster |**warn**|
21
21
|`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 |
22
23
|`clippy::nursery`| new lints that are still under development | allow |
23
24
|`clippy::cargo`| lints for the cargo manifest | allow |
24
25
25
26
More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!
26
27
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 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.
29
+
30
+
[^restrict]: Some use cases for `restriction` lints include:
31
+
32
+
* Strict coding styles.
33
+
* Additional restrictions on CI (e.g. `clippy::todo`).
34
+
* Preventing panicking in certain functions (e.g. `#[forbid(clippy::unwrap_used)]` on a module or function).
35
+
36
+
---
30
37
31
38
Table of contents:
32
39
33
-
*[Usage instructions](#usage)
34
-
*[Configuration](#configuration)
35
-
*[Contributing](#contributing)
36
-
*[License](#license)
40
+
*[Usage instructions](#usage)
41
+
*[Configuration](#configuration)
42
+
*[Contributing](#contributing)
43
+
*[License](#license)
37
44
38
45
## Usage
39
46
@@ -64,6 +71,7 @@ Once you have rustup and the latest stable release (at least Rust 1.29) installe
64
71
```terminal
65
72
rustup component add clippy
66
73
```
74
+
67
75
If it says that it can't find the `clippy` component, please run `rustup self update`.
68
76
69
77
#### Step 3: Run Clippy
@@ -143,16 +151,16 @@ line. (You can swap `clippy::all` with the specific lint category you are target
143
151
144
152
You can add options to your code to `allow`/`warn`/`deny` Clippy lints:
145
153
146
-
*the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).
154
+
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).
147
155
Note that `rustc` has additional [lint groups](https://doc.rust-lang.org/rustc/lints/groups.html).
148
156
149
-
*all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
157
+
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
150
158
`#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive
151
159
lints prone to false positives.
152
160
153
-
*only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
161
+
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
154
162
155
-
*`allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
163
+
*`allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
156
164
157
165
Note: `allow` means to suppress the lint for your code. With `warn` the lint
158
166
will only emit a warning, while with `deny` the lint will emit an error, when
0 commit comments