-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
Existing lint use_self
check impl
blocks for places where Self
could be used instead of explicit repetition of type.
The same can be done with recursive structs. For example:
struct X {
x: Option<Box<X>>, // <-- repetition
}
struct X {
x: Option<Box<Self>>, // <-- no repetition
}
Self
is very nice to have if the struct is modified to be generic.
struct X<'q, T: From<usize>> {
t: &'q T,
x: Option<Box<X<'q, T>>>, // <-- yuck
}
Opened as false negative, but might also be a "feature-request in a trench coat" 😆
Lint Name
use_self
Reproducer
Should raise use_self
:
struct X {
x: Option<Box<X>>, // <-- Self
}
struct X<'q, T: From<usize>> {
t: &'q T,
x: Option<Box<X<'q, T>>>, // <-- Self
}
Version
rustc 1.91.0-nightly (6ba0ce409 2025-08-21)
binary: rustc
commit-hash: 6ba0ce40941eee1ca02e9ba49c791ada5158747a
commit-date: 2025-08-21
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
zihan0822
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't