about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-26 08:48:12 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-26 08:48:12 +0000
commitead29847ffa929fc9b8fd8a7fd251fe9c17bfa76 (patch)
treee0ada131ac361c8765c92292541aa19d4a36c699
parent9d69da7d0e4308a4b479c9abe3e3e6e8d35032aa (diff)
parent3db14f182c4dce4d6ace923c291456e7d1249bc9 (diff)
downloadrust-ead29847ffa929fc9b8fd8a7fd251fe9c17bfa76.tar.gz
rust-ead29847ffa929fc9b8fd8a7fd251fe9c17bfa76.zip
Merge #3357
3357: Check existential types in `use_self` r=oli-obk a=HMPerson1

Fixes #3231

Co-authored-by: HMPerson1 <hmperson1@gmail.com>
-rw-r--r--clippy_lints/src/use_self.rs2
-rw-r--r--tests/ui/use_self.rs14
-rw-r--r--tests/ui/use_self.stderr8
3 files changed, 22 insertions, 2 deletions
diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs
index d770ea120eb..a8b7e820681 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 6ebe8f16a90..073d64d5a4b 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<Item=&Foo> {
+            foos.iter()
+        }
+
+        fn good(foos: &[Self]) -> impl Iterator<Item=&Self> {
+            foos.iter()
+        }
+    }
+}
diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr
index 627fc3a97cb..b71c7a9a4c5 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<Item=&Foo> {
+    |                                                      ^^^ help: use the applicable keyword: `Self`
+
+error: aborting due to 21 previous errors