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
Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
123
85
124
-
### As a Compiler Plugin
125
-
126
-
*Note:* This is not a recommended installation method.
127
-
128
-
Since stable Rust is backwards compatible, you should be able to
129
-
compile your stable programs with nightly Rust with clippy plugged in to
130
-
circumvent this.
131
-
132
-
Add in your `Cargo.toml`:
133
-
134
-
```toml
135
-
[dependencies]
136
-
clippy = "*"
137
-
```
138
-
139
-
You then need to add `#![feature(plugin)]` and `#![plugin(clippy)]` to the top
140
-
of your crate entry point (`main.rs` or `lib.rs`).
141
-
142
-
Sample `main.rs`:
143
-
144
-
```rust
145
-
#![feature(plugin)]
146
-
147
-
#![plugin(clippy)]
148
-
149
-
150
-
fnmain(){
151
-
letx=Some(1u8);
152
-
matchx {
153
-
Some(y) =>println!("{:?}", y),
154
-
_=> ()
155
-
}
156
-
}
157
-
```
158
-
159
-
Produces this warning:
160
-
161
-
```terminal
162
-
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
163
-
src/main.rs:8 match x {
164
-
src/main.rs:9 Some(y) => println!("{:?}", y),
165
-
src/main.rs:10 _ => ()
166
-
src/main.rs:11 }
167
-
src/main.rs:8:5: 11:6 help: Try
168
-
if let Some(y) = x { println!("{:?}", y) }
169
-
```
170
-
171
86
## Configuration
172
87
173
88
Some lints can be configured in a TOML file named with `clippy.toml` or `.clippy.toml`. It contains basic `variable = value` mapping eg.
See the [list of lints](https://rust-lang-nursery.github.io/rust-clippy/master/index.html) for more information about which lints can be configured and the
181
96
meaning of the variables.
182
97
183
-
You can also specify the path to the configuration file with:
0 commit comments