@@ -26,18 +26,35 @@ as an included feature during build. All of these options are detailed below.
26
26
27
27
As a general rule clippy will only work with the * latest* Rust nightly for now.
28
28
29
- ### Optional dependency
29
+ ### As a cargo subcommand (` cargo clippy ` )
30
+
31
+ One way to use clippy is by installing clippy through cargo as a cargo
32
+ subcommand.
33
+
34
+ ``` terminal
35
+ cargo install clippy
36
+ ```
37
+
38
+ Now you can run clippy by invoking ` cargo clippy ` , or
39
+ ` cargo +nightly clippy ` directly from a directory that is usually
40
+ compiled with stable.
41
+
42
+ In case you are not using rustup, you need to set the environment flag
43
+ ` SYSROOT ` during installation so clippy knows where to find ` librustc ` and
44
+ similar crates.
45
+
46
+ ``` terminal
47
+ SYSROOT=/path/to/rustc/sysroot cargo install clippy
48
+ ```
30
49
31
- If you want to make clippy an optional dependency, you can do the following:
50
+ ### Optional dependency
32
51
33
- In your ` Cargo.toml ` :
52
+ In some cases you might want to include clippy in your project directly, as an
53
+ optional dependency. To do this, just modify ` Cargo.toml ` :
34
54
35
55
``` toml
36
56
[dependencies ]
37
- clippy = {version = " *" , optional = true }
38
-
39
- [features ]
40
- default = []
57
+ clippy = { version = " *" , optional = true }
41
58
```
42
59
43
60
And, in your ` main.rs ` or ` lib.rs ` , add these lines:
@@ -54,25 +71,18 @@ Instead of adding the `cfg_attr` attributes you can also run clippy on demand:
54
71
(the ` -Z no trans ` , while not necessary, will stop the compilation process after
55
72
typechecking (and lints) have completed, which can significantly reduce the runtime).
56
73
57
- ### As a cargo subcommand ( ` cargo clippy ` )
74
+ Alternatively, to only run clippy when testing:
58
75
59
- An alternate way to use clippy is by installing clippy through cargo as a cargo
60
- subcommand.
61
-
62
- ``` terminal
63
- cargo install clippy
76
+ ``` toml
77
+ [dev-dependencies ]`
78
+ clippy = { version = " *" }
64
79
```
65
80
66
- Now you can run clippy by invoking ` cargo clippy ` , or
67
- ` rustup run nightly cargo clippy ` directly from a directory that is usually
68
- compiled with stable.
81
+ and add to ` main.rs ` or ` lib.rs ` :
69
82
70
- In case you are not using rustup, you need to set the environment flag
71
- ` SYSROOT ` during installation so clippy knows where to find ` librustc ` and
72
- similar crates.
73
-
74
- ``` terminal
75
- SYSROOT=/path/to/rustc/sysroot cargo install clippy
83
+ ```
84
+ #![cfg_attr(test, feature(plugin))]
85
+ #![cfg_attr(test, plugin(clippy))]
76
86
```
77
87
78
88
### Running clippy from the command line without installing
0 commit comments