@@ -18,8 +18,9 @@ Table of contents:
18
18
## Usage
19
19
20
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.
21
+ write better code, it is recommended not to include clippy as a hard dependency.
22
+ Options include using it as an optional dependency, as a cargo subcommand, or
23
+ as an included feature during build. All of these options are detailed below.
23
24
24
25
As a general rule clippy will only work with the * latest* Rust nightly for now.
25
26
@@ -52,8 +53,43 @@ Instead of adding the `cfg_attr` attributes you can also run clippy on demand:
52
53
(the ` -Z no trans ` , while not neccessary, will stop the compilation process after
53
54
typechecking (and lints) have completed, which can significantly reduce the runtime).
54
55
56
+ ### As a cargo subcommand (` cargo clippy ` )
57
+
58
+ An alternate way to use clippy is by installing clippy through cargo as a cargo
59
+ subcommand.
60
+
61
+ ``` terminal
62
+ cargo install clippy
63
+ ```
64
+
65
+ Now you can run clippy by invoking ` cargo clippy ` , or
66
+ ` rustup run nightly cargo clippy ` directly from a directory that is usually
67
+ compiled with stable.
68
+
69
+ In case you are not using rustup, you need to set the environment flag
70
+ ` SYSROOT ` during installation so clippy knows where to find ` librustc ` and
71
+ similar crates.
72
+
73
+ ``` terminal
74
+ SYSROOT=/path/to/rustc/sysroot cargo install clippy
75
+ ```
76
+
77
+ ### Running clippy from the command line without installing
78
+
79
+ To have cargo compile your crate with clippy without needing ` #![plugin(clippy)] `
80
+ in your code, you can use:
81
+
82
+ ``` terminal
83
+ cargo rustc -- -L /path/to/clippy_so -Z extra-plugins=clippy
84
+ ```
85
+
86
+ * [ Note] ( https://github.com/Manishearth/rust-clippy/wiki#a-word-of-warning ) :*
87
+ Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
88
+
55
89
### As a Compiler Plugin
56
90
91
+ * Note:* This is not a recommended installation method.
92
+
57
93
Since stable Rust is backwards compatible, you should be able to
58
94
compile your stable programs with nightly Rust with clippy plugged in to
59
95
circumvent this.
@@ -97,40 +133,6 @@ src/main.rs:8:5: 11:6 help: Try
97
133
if let Some(y) = x { println!("{:?}", y) }
98
134
```
99
135
100
- ### As a cargo subcommand (` cargo clippy ` )
101
-
102
- An alternate way to use clippy is by installing clippy through cargo as a cargo
103
- subcommand.
104
-
105
- ``` terminal
106
- cargo install clippy
107
- ```
108
-
109
- Now you can run clippy by invoking ` cargo clippy ` , or
110
- ` rustup run nightly cargo clippy ` directly from a directory that is usually
111
- compiled with stable.
112
-
113
- In case you are not using rustup, you need to set the environment flag
114
- ` SYSROOT ` during installation so clippy knows where to find ` librustc ` and
115
- similar crates.
116
-
117
- ``` terminal
118
- SYSROOT=/path/to/rustc/sysroot cargo install clippy
119
- ```
120
-
121
- ### Running clippy from the command line without installing
122
-
123
- To have cargo compile your crate with clippy without needing ` #![plugin(clippy)] `
124
- in your code, you can use:
125
-
126
- ``` terminal
127
- cargo rustc -- -L /path/to/clippy_so -Z extra-plugins=clippy
128
- ```
129
-
130
- * [ Note] ( https://github.com/Manishearth/rust-clippy/wiki#a-word-of-warning ) :*
131
- Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
132
-
133
-
134
136
## Configuration
135
137
136
138
Some lints can be configured in a ` clippy.toml ` file. It contains basic ` variable = value ` mapping eg.
0 commit comments