]> git.lizzy.rs Git - rust.git/commitdiff
Improve tests and exclude nested impls
authorWilco Kusee <wilcokusee@gmail.com>
Mon, 7 Jan 2019 13:11:53 +0000 (14:11 +0100)
committerWilco Kusee <wilcokusee@gmail.com>
Mon, 7 Jan 2019 13:11:53 +0000 (14:11 +0100)
clippy_lints/src/use_self.rs
tests/ui/use_self.rs
tests/ui/use_self.stderr

index 17078141af113a5efa545e7e6c090a79fa28cf89..5ec809f1b76cdcaa9ae1c0c4140233b12213b22d 100644 (file)
@@ -246,7 +246,8 @@ fn visit_item(&mut self, item: &'tcx Item) {
             | ItemKind::Static(..)
             | ItemKind::Enum(..)
             | ItemKind::Struct(..)
-            | ItemKind::Union(..) => {
+            | ItemKind::Union(..)
+            | ItemKind::Impl(..) => {
                 // Don't check statements that shadow `Self` or where `Self` can't be used
             },
             _ => walk_item(self, item),
index f3bd4a05005bd7b12e007041c1680c7d1baa0042..464dd8143292fb2297f7626639057e725459c219 100644 (file)
@@ -250,6 +250,14 @@ fn foo() {
             struct Bar {
                 foo: Foo, // Foo != Self
             }
+
+            impl Bar {
+                fn bar() -> Bar {
+                    Bar {
+                        foo: Foo{},
+                    }
+                }
+            }
         }
     }
 
@@ -258,7 +266,7 @@ enum Enum {
     }
     impl Enum {
         fn method() {
-            use self::Enum::*;
+            use self::Enum::*; // Issue 3425
             static STATIC: Enum = Enum::A; // Can't use Self as type
         }
     }
index 6c5dbf9111d6eb6083891a500b0e17ae15ddede6..a388579c9a3a329b1fbcdeed055638e8022dab71 100644 (file)
@@ -150,5 +150,17 @@ LL |                 Foo {}
 LL |         use_self_expand!(); // Should lint in local macros
    |         ------------------- in this macro invocation
 
-error: aborting due to 24 previous errors
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:255:29
+   |
+LL |                 fn bar() -> Bar {
+   |                             ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:256:21
+   |
+LL |                     Bar {
+   |                     ^^^ help: use the applicable keyword: `Self`
+
+error: aborting due to 26 previous errors