diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index d770ea120..a8b7e8206 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -226,6 +226,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> { } fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir) + NestedVisitorMap::All(&self.cx.tcx.hir) } } diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 6ebe8f16a..073d64d5a 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -205,3 +205,17 @@ mod issue2894 { } } } + +mod existential { + struct Foo; + + impl Foo { + fn bad(foos: &[Self]) -> impl Iterator { + foos.iter() + } + + fn good(foos: &[Self]) -> impl Iterator { + foos.iter() + } + } +} diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 627fc3a97..b71c7a9a4 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -120,5 +120,11 @@ error: unnecessary structure name repetition 119 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` -error: aborting due to 20 previous errors +error: unnecessary structure name repetition + --> $DIR/use_self.rs:213:54 + | +213 | fn bad(foos: &[Self]) -> impl Iterator { + | ^^^ help: use the applicable keyword: `Self` + +error: aborting due to 21 previous errors