Skip to content

Commit 6d0b70e

Browse files
committed
Clean up Allowing/Denying Lints section
1 parent 80bafa5 commit 6d0b70e

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

book/src/configuration.md

+22-14
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,29 @@ disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"]
3333
To deactivate the "for further information visit *lint-link*" message you can define the `CLIPPY_DISABLE_DOCS_LINKS`
3434
environment variable.
3535

36-
### Allowing/denying lints
36+
### Allowing/Denying Lints
3737

38-
You can add options to your code to `allow`/`warn`/`deny` Clippy lints:
38+
#### Attributes in Code
3939

40-
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`)
40+
You can add attributes to your code to `allow`/`warn`/`deny` Clippy lints:
4141

42-
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
43-
`#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive lints prone to false
44-
positives.
42+
* the whole set of `warn`-by-default lints using the `clippy` lint group (`#![allow(clippy::all)]`)
43+
44+
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![warn(clippy::all, clippy::pedantic)]`. Note
45+
that `clippy::pedantic` contains some very aggressive lints prone to false positives.
4546

4647
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
4748

4849
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
4950

5051
Note: `allow` means to suppress the lint for your code. With `warn` the lint will only emit a warning, while with `deny`
51-
the lint will emit an error, when triggering for your code. An error causes clippy to exit with an error code, so is
52-
useful in scripts like CI/CD.
52+
the lint will emit an error, when triggering for your code. An error causes Clippy to exit with an error code, so is
53+
most useful in scripts used in CI/CD.
54+
55+
#### Command Line Flags
5356

54-
If you do not want to include your lint levels in your code, you can globally enable/disable lints by passing extra
55-
flags to Clippy during the run:
57+
If you do not want to include your lint levels in the code, you can globally enable/disable lints by passing extra flags
58+
to Clippy during the run:
5659

5760
To allow `lint_name`, run
5861

@@ -66,28 +69,33 @@ And to warn on `lint_name`, run
6669
cargo clippy -- -W clippy::lint_name
6770
```
6871

69-
This also works with lint groups. For example, you can run Clippy with warnings for all lints enabled:
72+
This also works with lint groups. For example, you can run Clippy with warnings for all pedantic lints enabled:
7073

7174
```terminal
7275
cargo clippy -- -W clippy::pedantic
7376
```
7477

75-
If you care only about a single lint, you can allow all others and then explicitly warn on the lint(s) you are
78+
If you care only about a certain lints, you can allow all others and then explicitly warn on the lints you are
7679
interested in:
7780

7881
```terminal
7982
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
8083
```
8184

82-
The last way to allow/disallow lints is to use `Cargo.toml` using [the lints section](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-lints-section)):
85+
#### Lints Section in `Cargo.toml`
8386

84-
To deny `clippy::enum_glob_use`
87+
Finally, lints can be allowed/denied using [the lints
88+
section](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-lints-section)) in the `Cargo.toml` file:
89+
90+
To deny `clippy::enum_glob_use`, put the following in the `Cargo.toml`:
8591

8692
```toml
8793
[lints.clippy]
8894
enum_glob_use = "deny"
8995
```
9096

97+
For more details and options, refer to the Cargo documentation.
98+
9199
### Specifying the minimum supported Rust version
92100

93101
Projects that intend to support old versions of Rust can disable lints pertaining to newer features by specifying the

0 commit comments

Comments
 (0)