Skip to content

use_self False positive on enums that derive Serialize #9440

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

Closed
laralove143 opened this issue Sep 7, 2022 · 1 comment · Fixed by #9454
Closed

use_self False positive on enums that derive Serialize #9440

laralove143 opened this issue Sep 7, 2022 · 1 comment · Fixed by #9454
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@laralove143
Copy link

Summary

When an enum has #[derive(Serialize)], it triggers the use_self lint

Lint Name

use_self

Reproducer

I tried this code:

#![warn(clippy::use_self)]

use serde::Serialize;

#[derive(Serialize)]
pub enum Foo {
    Bar = 1,
}

I saw this happen:

warning: unnecessary structure name repetition
 --> src/lib.rs:6:10
  |
6 | pub enum Foo {
  |          ^^^ help: use the applicable keyword: `Self`
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(clippy::use_self)]
  |         ^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self

warning: `playground` (lib) generated 1 warning

I expected to see this happen:
No warnings

Version

Playground

Additional Labels

No response

@laralove143 laralove143 added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 7, 2022
@kraktus
Copy link
Contributor

kraktus commented Sep 10, 2022

duplicate of #6902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants