Skip to content
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

use_self false positive on derive #3909

Closed
lukasschlueter opened this issue Mar 30, 2019 · 0 comments · Fixed by #6179
Closed

use_self false positive on derive #3909

lukasschlueter opened this issue Mar 30, 2019 · 0 comments · Fixed by #6179

Comments

@lukasschlueter
Copy link

lukasschlueter commented Mar 30, 2019

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

bors added a commit that referenced this issue Jan 19, 2021
Rework use_self impl based on ty::Ty comparison #3410 | Take 2

This builds on top of #5531

I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary.

I would also appreciate your review `@montrivo,` since you are familiar with the challenges here.

Fixes #3410 and Fixes #4143 (same problem)
Fixes #2843
Fixes #3859
Fixes #4734 and fixes #6221
Fixes #4305
Fixes #5078 (even at expression level now 🎉)
Fixes #3881 and Fixes #4887 (same problem)
Fixes #3909

Not yet: #4140 (test added)

All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code.

changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
bors added a commit that referenced this issue Feb 10, 2021
Rework use_self impl based on ty::Ty comparison #3410 | Take 2

This builds on top of #5531

I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary.

I would also appreciate your review `@montrivo,` since you are familiar with the challenges here.

Fixes #3410 and Fixes #4143 (same problem)
Fixes #2843
Fixes #3859
Fixes #4734 and fixes #6221
Fixes #4305
Fixes #5078 (even at expression level now 🎉)
Fixes #3881 and Fixes #4887 (same problem)
Fixes #3909

Not yet: #4140 (test added)

All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code.

changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
@bors bors closed this as completed in 605e9ba Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant