-
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
triggers false positive on other mod items and the suggestion is wrong.
Lint Name
use_self
Reproducer
I tried this code:
mod a {
pub struct Foo;
}
mod b {
use crate::a;
struct Foo;
impl From<Foo> for a::Foo {
fn from(_: Foo) -> a::Foo {
a::Foo
}
}
}
I saw this happen:
error: unnecessary structure name repetition
--> src/lib.rs:11:28
|
11 | fn from(_: Foo) -> a::Foo {
| ^^^^^^ help: use the applicable keyword: `Self`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
= note: `-D clippy::use-self` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::use_self)]`
error: unnecessary structure name repetition
--> src/lib.rs:12:13
|
12 | a::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.
Version
rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: aarch64-apple-darwin
release: 1.84.0
LLVM version: 19.1.5
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