num-derive icon indicating copy to clipboard operation
num-derive copied to clipboard

Use of `num_derive::FromPrimitive` throws Clippy lint `clippy::use_self`

Open Fuwn opened this issue 3 years ago • 5 comments

I've just bumped my tool-chain release up from nightly-2021-02-20 to nightly-2021-06-04 and a new warning arises for the num_derive::FromPrimitive derive macro.

The Clippy lint clippy::use_self is thrown for the following derive macro use-case:

Fuwn avatar Jun 06 '21 05:06 Fuwn

ref: https://rust-lang.github.io/rust-clippy/master/#use_self

That's currently labeled "Nursery" and is allowed by default. I find that a rather pedantic style lint, and not really relevant to macro-generated code. That said, if Self does work in that position even in MSRV 1.31, I'd be fine with a PR changing it.

cuviper avatar Jun 07 '21 16:06 cuviper

While I'm at it, you mind if I fix any other Clippy lints that come up do you prefer I just patch this one instance?

Fuwn avatar Jun 07 '21 18:06 Fuwn

Actually, this lint might not even originate from the num-derive crate, I strictly denied the clippy::use_self lint and not a single lint presented itself, I then required the crate from a local path and the lint is still present. Might be a Clippy false-positive.

Fuwn avatar Jun 07 '21 20:06 Fuwn

Ah, there are subtle differences in how "local" crates are treated for stuff like this. I know that "remote" crates are built with --cap-lints allow, but I'm not exactly sure how that affects proc-macro-generated code.

cuviper avatar Jun 07 '21 23:06 cuviper

The same problem haunts a number of other crates. It is tracked in clippy here: https://github.com/rust-lang/rust-clippy/issues/6902

barafael avatar May 02 '22 19:05 barafael

Clippy seems to exempt the proc-macro code now! rust-lang/rust-clippy#8694

cuviper avatar Nov 02 '22 19:11 cuviper