-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansiongood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
cargo clippy -V: clippy 0.0.212 (c807fbc 2019-12-29)
rustc -V: rustc 1.42.0-nightly (da3629b 2019-12-29)
Summary
Deriving Debug
on a struct with at least one field triggers let-underscore-must-use
lint.
Steps to reproduce
Given the following code:
#[derive(Debug)]
struct Foo {
field: i32,
}
fn main() {
}
When cargo clippy -- -W clippy::let-underscore-must-use
is run it emits a warning:
warning: non-binding let on an expression with #[must_use] type
--> src/main.rs:1:10
|
1 | #[derive(Debug)]
| ^^^^^
|
= note: requested on the command line with `-W clippy::let-underscore-must-use`
= help: consider explicitly using expression value
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_must_use
If we run cargo expand
, we can see the compiler generates an anonymous binding indeed:
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Foo {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match *self {
Foo {
field: ref __self_0_0,
} => {
let mut debug_trait_builder = f.debug_struct("Foo");
let _ = debug_trait_builder.field("field", &&(*__self_0_0));
debug_trait_builder.finish()
}
}
}
}
mwilliammyers
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansiongood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy