Skip to content

Commit 8631a1e

Browse files
committed
Update readme description of restriction lints to dissuade casual use.
1 parent 5ef3cc8 commit 8631a1e

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,31 @@ 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

2526
More 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+
35+
* Strict coding styles.
36+
* Additional restrictions on CI (e.g. `clippy::todo`).
37+
* Preventing panicking in certain functions (e.g. `#[forbid(clippy::unwrap_used)]` on a module or function).
38+
39+
---
3040

3141
Table of contents:
3242

33-
* [Usage instructions](#usage)
34-
* [Configuration](#configuration)
35-
* [Contributing](#contributing)
36-
* [License](#license)
43+
* [Usage instructions](#usage)
44+
* [Configuration](#configuration)
45+
* [Contributing](#contributing)
46+
* [License](#license)
3747

3848
## Usage
3949

@@ -64,6 +74,7 @@ Once you have rustup and the latest stable release (at least Rust 1.29) installe
6474
```terminal
6575
rustup component add clippy
6676
```
77+
6778
If it says that it can't find the `clippy` component, please run `rustup self update`.
6879

6980
#### Step 3: Run Clippy
@@ -143,16 +154,16 @@ line. (You can swap `clippy::all` with the specific lint category you are target
143154

144155
You can add options to your code to `allow`/`warn`/`deny` Clippy lints:
145156

146-
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).
157+
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).
147158
Note that `rustc` has additional [lint groups](https://doc.rust-lang.org/rustc/lints/groups.html).
148159

149-
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
160+
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
150161
`#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive
151162
lints prone to false positives.
152163

153-
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
164+
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
154165

155-
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
166+
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
156167

157168
Note: `allow` means to suppress the lint for your code. With `warn` the lint
158169
will only emit a warning, while with `deny` the lint will emit an error, when
@@ -176,12 +187,14 @@ cargo clippy -- -W clippy::lint_name
176187

177188
This also works with lint groups. For example, you
178189
can run Clippy with warnings for all lints enabled:
190+
179191
```terminal
180192
cargo clippy -- -W clippy::pedantic
181193
```
182194

183195
If you care only about a single lint, you can allow all others and then explicitly warn on
184196
the lint(s) you are interested in:
197+
185198
```terminal
186199
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
187200
```

0 commit comments

Comments
 (0)