-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
use_self
seems to trigger even when the lifetimes are different here. Using --fix
doesn't work as the resulting code doesn't compile. (Which is good that --fix doesn't try to fix anything then)
Lint Name
use_self
Reproducer
#![warn(clippy::use_self)]
trait Foo {
type Item<'foo>;
}
struct Bar<'b> {
content: &'b str,
}
impl<'b> Foo for Option<Bar<'b>> {
type Item<'foo> = Option<Bar<'foo>>;
}
I saw this happen:
warning: unnecessary structure name repetition
--> src/main.rs:16:23
|
16 | type Item<'foo> = Option<Bar<'foo>>;
| ^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
I expected to see this happen: The lint should not trigger here. These are different lifetimes.
Version
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have