Skip to content

-Wclippy::nursery generates use_self when enum derives strum_macros::Display #8910

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
Guilherme-Vasconcelos opened this issue May 29, 2022 · 1 comment · Fixed by #9454
Closed
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

@Guilherme-Vasconcelos
Copy link
Contributor

Summary

I am using the strum and strum_macros crates, both on version 0.24.0.

When an enum derives strum_macros::Display and clippy is invoked with -Wclippy::nursery (i.e. cargo clippy -- -Wclippy::nursery), a warning is generated telling me to replace the enum's name with Self.

Lint Name

clippy::use-self

Reproducer

I tried this code:

//// on Cargo.toml
[package]
name = "testing"
edition = "2021"
version = "0.0.1"

[dependencies]
strum = "0.24.0"
strum_macros = "0.24.0"

//// on src/main.rs
mod bug;

fn main() {}

//// on src/bug.rs
use strum_macros::Display;

#[allow(dead_code)]
#[derive(Display)]
enum MyTest {
    Testing
}

I saw this happen:

warning: unnecessary structure name repetition
 --> src/bug.rs:5:6
  |
5 | enum MyTest {
  |      ^^^^^^ help: use the applicable keyword: `Self`
  |
  = note: `-W clippy::use-self` implied by `-W clippy::nursery`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self

warning: `testing` (bin "testing") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s

enum Self here would not be valid.

Version

rustc 1.61.0 (Arch Linux rust 1:1.61.0-1)
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 13.0.1

Additional Labels

No response

@Guilherme-Vasconcelos Guilherme-Vasconcelos 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 May 29, 2022
@giraffate
Copy link
Contributor

It might be a 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