@@ -17,8 +17,41 @@ Table of contents:
17
17
18
18
## Usage
19
19
20
+ Since this is a tool for helping the developer of a library or application
21
+ write better code, it is recommended to include clippy as an optional
22
+ dependency.
23
+
20
24
As a general rule clippy will only work with the * latest* Rust nightly for now.
21
25
26
+ ### Optional dependency
27
+
28
+ If you want to make clippy an optional dependency, you can do the following:
29
+
30
+ In your ` Cargo.toml ` :
31
+
32
+ ``` toml
33
+ [dependencies ]
34
+ clippy = {version = " *" , optional = true }
35
+
36
+ [features ]
37
+ default = []
38
+ ```
39
+
40
+ And, in your ` main.rs ` or ` lib.rs ` :
41
+
42
+ ``` rust
43
+ #![cfg_attr(feature= " clippy" , feature(plugin))]
44
+
45
+ #![cfg_attr(feature= " clippy" , plugin(clippy))]
46
+ ```
47
+
48
+ Then build by enabling the feature: ` cargo build --features "clippy" `
49
+
50
+ Instead of adding the ` cfg_attr ` attributes you can also run clippy on demand:
51
+ ` cargo rustc --features clippy -- -Z no-trans -Z extra-plugins=clippy `
52
+ (the ` -Z no trans ` , while not neccessary, will stop the compilation process after
53
+ typechecking (and lints) have completed, which can significantly reduce the runtime).
54
+
22
55
### As a Compiler Plugin
23
56
24
57
Since stable Rust is backwards compatible, you should be able to
@@ -97,34 +130,6 @@ cargo rustc -- -L /path/to/clippy_so -Z extra-plugins=clippy
97
130
* [ Note] ( https://github.com/Manishearth/rust-clippy/wiki#a-word-of-warning ) :*
98
131
Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
99
132
100
- ### Optional dependency
101
-
102
- If you want to make clippy an optional dependency, you can do the following:
103
-
104
- In your ` Cargo.toml ` :
105
-
106
- ``` toml
107
- [dependencies ]
108
- clippy = {version = " *" , optional = true }
109
-
110
- [features ]
111
- default = []
112
- ```
113
-
114
- And, in your ` main.rs ` or ` lib.rs ` :
115
-
116
- ``` rust
117
- #![cfg_attr(feature= " clippy" , feature(plugin))]
118
-
119
- #![cfg_attr(feature= " clippy" , plugin(clippy))]
120
- ```
121
-
122
- Then build by enabling the feature: ` cargo build --features "clippy" `
123
-
124
- Instead of adding the ` cfg_attr ` attributes you can also run clippy on demand:
125
- ` cargo rustc --features clippy -- -Z no-trans -Z extra-plugins=clippy `
126
- (the ` -Z no trans ` , while not neccessary, will stop the compilation process after
127
- typechecking (and lints) have completed, which can significantly reduce the runtime).
128
133
129
134
## Configuration
130
135
0 commit comments