Skip to content

use_self False positive on enums that derive Serialize #9440

Closed
@laralove143

Description

@laralove143

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions