Skip to content

use_self false positive on derive #3909

@lukasschlueter

Description

@lukasschlueter

Hi,

I think I've found a false positive for the use_self lint.
As far as I could tell, it's not covered by some other issue yet.

It appears that Clippy is running the lint for code that is getting #derived.
Here's an example:

#[macro_use]
extern crate relm_derive;

#[derive(Msg)]
enum M {
    Quit,
}

Output:

warning: unnecessary structure name repetition
 --> src/main.rs:5:6
  |
6 | enum M {
  |      ^ help: use the applicable keyword: `Self`
  |
  = note: requested on the command line with `-W clippy::use-self`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
$ cargo clippy -V
clippy 0.0.212 (92612c9 2019-03-18)

I'm not familiar with the way #derive works so I couldn't really reduce this down to a minimal example without dependencies.
However, I think the lint should not be applied to external dependencies.

Edit:
I tried to disable the lint for the enum with #[allow(clippy::use_self)] but it didn't have an effect:

#[derive(Msg)]
#[allow(clippy::use_self)]
enum M {
    Quit,
}

Kind regards,
Lukas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions