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
To deactivate the "for further information visit *lint-link*" message you can define the `CLIPPY_DISABLE_DOCS_LINKS`
34
34
environment variable.
35
35
36
-
### Allowing/denying lints
36
+
### Allowing/Denying Lints
37
37
38
-
You can add options to your code to `allow`/`warn`/`deny` Clippy lints:
38
+
#### Attributes in Code
39
39
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:
41
41
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.
45
46
46
47
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)
47
48
48
49
*`allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.
49
50
50
51
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
53
56
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:
56
59
57
60
To allow `lint_name`, run
58
61
@@ -66,28 +69,33 @@ And to warn on `lint_name`, run
66
69
cargo clippy -- -W clippy::lint_name
67
70
```
68
71
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:
70
73
71
74
```terminal
72
75
cargo clippy -- -W clippy::pedantic
73
76
```
74
77
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
76
79
interested in:
77
80
78
81
```terminal
79
82
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
80
83
```
81
84
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`
83
86
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`:
85
91
86
92
```toml
87
93
[lints.clippy]
88
94
enum_glob_use = "deny"
89
95
```
90
96
97
+
For more details and options, refer to the Cargo documentation.
98
+
91
99
### Specifying the minimum supported Rust version
92
100
93
101
Projects that intend to support old versions of Rust can disable lints pertaining to newer features by specifying the
0 commit comments