Closed
Description
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