-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
let-underscore-must-use is triggered when Debug is derived #4980
Comments
Here is some analysis of what is going on. Running
It's a bug in the lint but I'm not sure what the best way of fixing it would be. |
There are two separate problems here:
The second one relates to the need to call The first one could be solved by checking if the object pointed by the reference is used, not just the reference returned from the function. I don't know if Clippy is capable of such call analysis, especially when in general the object could be passed away from the place of its construction and used much later in some other part of the program. |
I think it's save to just disable this lint in external macros. |
disable let_underscore_must_use in external macros changelog: disable let_underscore_must_use in external macros Closes #4980
This is still an issue when using other crates to derive traits. Here is an example using #![deny(clippy::let_underscore_must_use)]
use derivative::Derivative; // 2.2.0
#[derive(Derivative)]
#[derivative(Debug)]
struct S {
x: i32,
} Output from clippy:
|
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 triggerslet-underscore-must-use
lint.Steps to reproduce
Given the following code:
When
cargo clippy -- -W clippy::let-underscore-must-use
is run it emits a warning:If we run
cargo expand
, we can see the compiler generates an anonymous binding indeed:The text was updated successfully, but these errors were encountered: