Closed
Description
I'm trying to add clippy to diesel (again), and just got this:
error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> /Users/pascal/Projekte/tools/diesel/diesel/src/types/impls/tuples.rs:145:25
|
145 | match self.$idx {
| _________________________^ starting here...
146 | | ColumnInsertValue::Expression(_, ref value) => {
147 | | try!(value.collect_binds(out));
148 | | }
149 | | _ => {}
150 | | }
| |_________________________^ ...ending here
...
296 | tuple_impls! {
| - in this macro invocation
|
note: lint level defined here
--> /Users/pascal/Projekte/tools/diesel/diesel/src/lib.rs:7:9
|
7 | #![deny(warnings, missing_debug_implementations, missing_copy_implementations)]
| ^^^^^^^^
help: try this
| if let ColumnInsertValue::Expression(_, ref value) = self.$idx {
| ColumnInsertValue::Expression(_, ref value) => {
| try!(value.collect_binds(out));
| }
| _ => {}
| }
...
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#single_match
The suggestion contains the correct line for if-let itself, but the body is an exact copy of the match arms, not the expression on the right side of the single match arm.
The correct suggestion would be:
if let ColumnInsertValue::Expression(_, ref value) = self.$idx {
try!(value.collect_binds(out));
}
As you can see, this is inside a macro. I can try to make a smaller example to reproduce this if you want.