This occurred with Clippy 0.0.195 on rustc 1.27.0-nightly (ac3c2288f 2018-04-18). The following code triggered the useless_attribute lint on the derive line even though it clearly should not be:
#[derive(Deserialize, Default)]
#[serde(deny_unknown_fields)]
pub struct Config {
#[serde(default)]
pub print_schema: PrintSchema,
}
Seen in this travis build for Diesel: https://travis-ci.org/diesel-rs/diesel/jobs/399697117#L616
Seems to work with latest Clippy: playgound link
I'm actually not convinced it's related to the clippy version -- I can't replicate the failure locally. We also did not change the clippy version used or the nightly used, the travis build just started failing from this for no apparent reason. The span for the lint also looks completely wrong, as it's not a full attribute.
Did you bump the serde version? Maybe it's proc macro related
Ah, you're right. cargo update led to Updating serde_derive v1.0.66 -> v1.0.70 and I'm now able to reproduce locally. All that said, I'm not sure where to open this bug. I don't think that repro script shows that this doesn't occur on the latest clippy version, we have plenty of other #[derive(Deserialize)] that work just fine, only this one spot is causing the lint to fail. The proc_macro2 version did not change.
Wonderful! I'll investigate what changed in those serde versions
This might be unrelated but it looks like the build uses two different versions of proc-macro2.
Compiling proc-macro2 v0.4.6
Compiling proc-macro2 v0.3.8
That was true before this issue occurred
One thing that didn't get explicitly mentioned that I just noticed, Clippy thinks that derive is a lint here.
I got the same issue.
rustc 1.29.0-nightly (64f7de921 2018-07-12)
clippy https://github.com/rust-lang-nursery/rust-clippy/commit/06d6710147742892efc17ed307b3397bfe093bc7
cargo log: https://pastebin.com/Qjmv06iJ
Only derive with serde are affected.
Is there any advice on dealing with this? I just started seeing this on a codebase that hasn't changed in a few weeks:
|
21 | #[derive(Copy, Clone, Debug, PartialEq, FromPrimitive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![derive(Copy, Clone, Debug, PartialEq, FromPrimitive`
|
I'm seeing the same issue. In my case it's with FromPrimitive and ToPrimitive from num-derive (version 0.2.3)
Also seeing the issue with FromPrimitive, in akavel/nixme → src/lib.rs l.61 (warning: newbie code!)
error: useless lint attribute
--> src\lib.rs:61:1
|
61 | #[derive(FromPrimitive)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(clippy::useless_attribute)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/master/index.html#useless_attribute
Not 100% sure yet, but this may be fixable in a similar way as https://github.com/rust-lang/rust-clippy/pull/3535/commits/bcbbb4d09b2f474614134730e84afad04d2d8e48. I will try to come up with a minimal example that doesn't depend on external crates.
I just managed to reproduce this using the num_derive crate and hope to have a fix PR up tomorrow.
Most helpful comment
I'm seeing the same issue. In my case it's with
FromPrimitiveandToPrimitivefromnum-derive(version 0.2.3)