-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clippy complains about clippy::match_single_binding when deriving Debug #58
Comments
+1 |
Hi, Thanks for the repport, but I consider this to be a bug in Clippy: It should not generate that kind of warning in generated code. Please report the issue over there. |
FYI I filed a clippy issue, as I didn't see one: rust-lang/rust-clippy#5362 |
- mcarton/rust-derivative#58 - some misc. stuff I just introduced
I'm not sure this is a clippy issue. Clippy already checks for expansions (https://github.com/rust-lang/rust-clippy/blob/09fe163c9290b8aa573decb25d5b4b02f33e481e/clippy_lints/src/matches.rs#L367), but since you are reusing the Lines 84 to 92 in abcb0ec
Shouldn't it work just fine if you used |
@oli-cosmian The thing with making new spans is that it usually makes worse error messages. |
Fixed in #71. |
fixed by upgrading derivative to latest Clippy output: Checking process_execution v0.0.1 (/Users/tdyas/TC/pants/src/rust/engine/process_execution) error: this match could be written as a `let` statement --> process_execution/src/remote.rs:37:1 | 37 | #[derivative(Debug)] | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> process_execution/src/lib.rs:7:3 | 7 | clippy::all, | ^^^^^^^^^^^ = note: `#[deny(clippy::match_single_binding)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding help: consider using `let` statement | 37 | let Derivative = #[derivative(Debug)]; 38 | Derivative See mcarton/rust-derivative#58. Fix was released in vw2.1.1.
fixed by upgrading derivative to latest Clippy output: Checking process_execution v0.0.1 (/Users/tdyas/TC/pants/src/rust/engine/process_execution) error: this match could be written as a `let` statement --> process_execution/src/remote.rs:37:1 | 37 | #[derivative(Debug)] | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> process_execution/src/lib.rs:7:3 | 7 | clippy::all, | ^^^^^^^^^^^ = note: `#[deny(clippy::match_single_binding)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding help: consider using `let` statement | 37 | let Derivative = #[derivative(Debug)]; 38 | Derivative See mcarton/rust-derivative#58. Fix was released in vw2.1.1.
fixed by upgrading derivative to latest Clippy output: Checking process_execution v0.0.1 (/Users/tdyas/TC/pants/src/rust/engine/process_execution) error: this match could be written as a `let` statement --> process_execution/src/remote.rs:37:1 | 37 | #[derivative(Debug)] | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> process_execution/src/lib.rs:7:3 | 7 | clippy::all, | ^^^^^^^^^^^ = note: `#[deny(clippy::match_single_binding)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding help: consider using `let` statement | 37 | let Derivative = #[derivative(Debug)]; 38 | Derivative See mcarton/rust-derivative#58. Fix was released in vw2.1.1.
fixed by upgrading derivative to latest Clippy output: Checking process_execution v0.0.1 (/Users/tdyas/TC/pants/src/rust/engine/process_execution) error: this match could be written as a `let` statement --> process_execution/src/remote.rs:37:1 | 37 | #[derivative(Debug)] | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> process_execution/src/lib.rs:7:3 | 7 | clippy::all, | ^^^^^^^^^^^ = note: `#[deny(clippy::match_single_binding)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding help: consider using `let` statement | 37 | let Derivative = #[derivative(Debug)]; 38 | Derivative See mcarton/rust-derivative#58. Fix was released in vw2.1.1.
fixed by upgrading derivative to latest Clippy output: Checking process_execution v0.0.1 (/Users/tdyas/TC/pants/src/rust/engine/process_execution) error: this match could be written as a `let` statement --> process_execution/src/remote.rs:37:1 | 37 | #[derivative(Debug)] | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> process_execution/src/lib.rs:7:3 | 7 | clippy::all, | ^^^^^^^^^^^ = note: `#[deny(clippy::match_single_binding)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding help: consider using `let` statement | 37 | let Derivative = #[derivative(Debug)]; 38 | Derivative See mcarton/rust-derivative#58. Fix was released in vw2.1.1. # Delete this line to force CI to run the JVM tests. [ci skip-jvm-tests]
Fresh clippy [as of 2020-02-16] is not happy about
match
code generated when derivingDebug
To Reproduce
Here is the code that shows the problem
Expected behavior
warning-clean code
Errors
warning: this match could be written as a
let
statement--> examples/let.rs:6:1
|
6 | #[derivative(Debug)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note:
#[warn(clippy::match_single_binding)]
on by default= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using
let
statement|
6 | let Derivative = #[derivative(Debug)];
7 | Derivative
|
Version (please complete the following information):
Please include the output of the following commands, and any other version you think is relevant:
derivative
: 1.0.3Additional context
running
cargo expand
shows what makes clippy unhappyThe
match *self
seems to be the source of griefThe text was updated successfully, but these errors were encountered: