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
+157-157
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,163 @@ Table of contents:
15
15
*[*clippy-service*](#link-with-clippy-service)
16
16
*[License](#license)
17
17
18
+
## Usage
19
+
20
+
As a general rule clippy will only work with the *latest* Rust nightly for now.
21
+
22
+
### As a Compiler Plugin
23
+
24
+
Since stable Rust is backwards compatible, you should be able to
25
+
compile your stable programs with nightly Rust with clippy plugged in to
26
+
circumvent this.
27
+
28
+
Add in your `Cargo.toml`:
29
+
30
+
```toml
31
+
[dependencies]
32
+
clippy = "*"
33
+
```
34
+
35
+
You then need to add `#![feature(plugin)]` and `#![plugin(clippy)]` to the top
36
+
of your crate entry point (`main.rs` or `lib.rs`).
37
+
38
+
Sample `main.rs`:
39
+
40
+
```rust
41
+
#![feature(plugin)]
42
+
43
+
#![plugin(clippy)]
44
+
45
+
46
+
fnmain(){
47
+
letx=Some(1u8);
48
+
matchx {
49
+
Some(y) =>println!("{:?}", y),
50
+
_=> ()
51
+
}
52
+
}
53
+
```
54
+
55
+
Produces this warning:
56
+
57
+
```terminal
58
+
src/main.rs:8:5: 11:6 warning: you seem to be trying to use match for destructuring a single type. Consider using `if let`, #[warn(single_match)] on by default
59
+
src/main.rs:8 match x {
60
+
src/main.rs:9 Some(y) => println!("{:?}", y),
61
+
src/main.rs:10 _ => ()
62
+
src/main.rs:11 }
63
+
src/main.rs:8:5: 11:6 help: Try
64
+
if let Some(y) = x { println!("{:?}", y) }
65
+
```
66
+
67
+
### As a cargo subcommand (`cargo clippy`)
68
+
69
+
An alternate way to use clippy is by installing clippy through cargo as a cargo
70
+
subcommand.
71
+
72
+
```terminal
73
+
cargo install clippy
74
+
```
75
+
76
+
Now you can run clippy by invoking `cargo clippy`, or
77
+
`rustup run nightly cargo clippy` directly from a directory that is usually
78
+
compiled with stable.
79
+
80
+
In case you are not using rustup, you need to set the environment flag
81
+
`SYSROOT` during installation so clippy knows where to find `librustc` and
To deactivate the “for further information visit *wiki-link*” message you can
148
+
define the `CLIPPY_DISABLE_WIKI_LINKS` environment variable.
149
+
150
+
### Allowing/denying lints
151
+
152
+
You can add options to `allow`/`warn`/`deny`:
153
+
154
+
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy)]`)
155
+
156
+
* all lints using both the `clippy` and `clippy_pedantic` lint groups (`#![deny(clippy)]`,
157
+
`#![deny(clippy_pedantic)]`). Note that `clippy_pedantic` contains some very aggressive
158
+
lints prone to false positives.
159
+
160
+
* only some lints (`#![deny(single_match, box_vec)]`, etc)
161
+
162
+
*`allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc
163
+
164
+
Note: `deny` produces errors instead of warnings.
165
+
166
+
## Link with clippy service
167
+
168
+
`clippy-service` is a rust web initiative providing `rust-clippy` as a web service.
169
+
170
+
Both projects are independent and maintained by different people
171
+
(even if some `clippy-service`'s contributions are authored by some `rust-clippy` members).
172
+
173
+
You can check out this great service at [clippy.bashy.io](https://clippy.bashy.io/).
174
+
18
175
## Lints
19
176
20
177
There are 171 lints included in this crate:
@@ -195,163 +352,6 @@ name
195
352
196
353
More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/issues) if you have ideas!
197
354
198
-
## Usage
199
-
200
-
As a general rule clippy will only work with the *latest* Rust nightly for now.
201
-
202
-
### As a Compiler Plugin
203
-
204
-
Since stable Rust is backwards compatible, you should be able to
205
-
compile your stable programs with nightly Rust with clippy plugged in to
206
-
circumvent this.
207
-
208
-
Add in your `Cargo.toml`:
209
-
210
-
```toml
211
-
[dependencies]
212
-
clippy = "*"
213
-
```
214
-
215
-
You then need to add `#![feature(plugin)]` and `#![plugin(clippy)]` to the top
216
-
of your crate entry point (`main.rs` or `lib.rs`).
217
-
218
-
Sample `main.rs`:
219
-
220
-
```rust
221
-
#![feature(plugin)]
222
-
223
-
#![plugin(clippy)]
224
-
225
-
226
-
fnmain(){
227
-
letx=Some(1u8);
228
-
matchx {
229
-
Some(y) =>println!("{:?}", y),
230
-
_=> ()
231
-
}
232
-
}
233
-
```
234
-
235
-
Produces this warning:
236
-
237
-
```terminal
238
-
src/main.rs:8:5: 11:6 warning: you seem to be trying to use match for destructuring a single type. Consider using `if let`, #[warn(single_match)] on by default
239
-
src/main.rs:8 match x {
240
-
src/main.rs:9 Some(y) => println!("{:?}", y),
241
-
src/main.rs:10 _ => ()
242
-
src/main.rs:11 }
243
-
src/main.rs:8:5: 11:6 help: Try
244
-
if let Some(y) = x { println!("{:?}", y) }
245
-
```
246
-
247
-
### As a cargo subcommand (`cargo clippy`)
248
-
249
-
An alternate way to use clippy is by installing clippy through cargo as a cargo
250
-
subcommand.
251
-
252
-
```terminal
253
-
cargo install clippy
254
-
```
255
-
256
-
Now you can run clippy by invoking `cargo clippy`, or
257
-
`rustup run nightly cargo clippy` directly from a directory that is usually
258
-
compiled with stable.
259
-
260
-
In case you are not using rustup, you need to set the environment flag
261
-
`SYSROOT` during installation so clippy knows where to find `librustc` and
0 commit comments