about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2020-10-16 13:26:02 +0200
committerflip1995 <philipp.krones@embecosm.com>2021-02-10 11:57:28 +0100
commitbb40db7adc6c42fb675559b7ac92468ed416747f (patch)
tree9dfb40efd83a5d82408082298770e58451bae514
parentae2dd671f5003e6722ca4d18ef447141db237213 (diff)
downloadrust-bb40db7adc6c42fb675559b7ac92468ed416747f.tar.gz
rust-bb40db7adc6c42fb675559b7ac92468ed416747f.zip
Update test files
-rw-r--r--tests/ui/use_self.fixed41
-rw-r--r--tests/ui/use_self.rs21
-rw-r--r--tests/ui/use_self.stderr140
-rw-r--r--tests/ui/use_self_trait.fixed15
-rw-r--r--tests/ui/use_self_trait.rs1
-rw-r--r--tests/ui/use_self_trait.stderr82
6 files changed, 208 insertions, 92 deletions
diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed
index d59750cbfd8..1632e6aca44 100644
--- a/tests/ui/use_self.fixed
+++ b/tests/ui/use_self.fixed
@@ -3,7 +3,7 @@
 
 #![warn(clippy::use_self)]
 #![allow(dead_code)]
-#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms)]
+#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms, clippy::from_over_into)]
 
 fn main() {}
 
@@ -15,16 +15,13 @@ mod use_self {
             Self {}
         }
         fn test() -> Self {
-            // FIXME: applicable here
-            Foo::new()
+            Self::new()
         }
     }
 
     impl Default for Foo {
-        // FIXME: applicable here
-        fn default() -> Foo {
-            // FIXME: applicable here
-            Foo::new()
+        fn default() -> Self {
+            Self::new()
         }
     }
 }
@@ -74,13 +71,12 @@ mod lifetimes {
 
 mod issue2894 {
     trait IntoBytes {
-        #[allow(clippy::wrong_self_convention)]
-        fn into_bytes(&self) -> Vec<u8>;
+        fn to_bytes(&self) -> Vec<u8>;
     }
 
     // This should not be linted
     impl IntoBytes for u8 {
-        fn into_bytes(&self) -> Vec<u8> {
+        fn to_bytes(&self) -> Vec<u8> {
             vec![*self]
         }
     }
@@ -90,11 +86,7 @@ mod existential {
     struct Foo;
 
     impl Foo {
-        // FIXME:
-        // TyKind::Def (used for `impl Trait` types) does not include type parameters yet.
-        // See documentation in rustc_hir::hir::TyKind.
-        // The hir tree walk stops at `impl Iterator` level and does not inspect &Foo.
-        fn bad(foos: &[Self]) -> impl Iterator<Item = &Foo> {
+        fn bad(foos: &[Self]) -> impl Iterator<Item = &Self> {
             foos.iter()
         }
 
@@ -215,10 +207,8 @@ mod rustfix {
         fn fun_1() {}
 
         fn fun_2() {
-            // FIXME: applicable here
-            nested::A::fun_1();
-            // FIXME: applicable here
-            nested::A::A;
+            Self::fun_1();
+            Self::A;
 
             Self {};
         }
@@ -239,8 +229,7 @@ mod issue3567 {
 
     impl Test for TestStruct {
         fn test() -> TestStruct {
-            // FIXME: applicable here
-            TestStruct::from_something()
+            Self::from_something()
         }
     }
 }
@@ -254,14 +243,12 @@ mod paths_created_by_lowering {
         const A: usize = 0;
         const B: usize = 1;
 
-        // FIXME: applicable here
-        async fn g() -> S {
+        async fn g() -> Self {
             Self {}
         }
 
         fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
-            // FIXME: applicable here twice
-            &p[S::A..S::B]
+            &p[Self::A..Self::B]
         }
     }
 
@@ -381,7 +368,6 @@ mod issue4305 {
 
     impl<T: Foo> From<T> for Box<dyn Foo> {
         fn from(t: T) -> Self {
-            // FIXME: applicable here
             Box::new(t)
         }
     }
@@ -461,8 +447,7 @@ mod nested_paths {
 
     impl A<submod::C> {
         fn test() -> Self {
-            // FIXME: applicable here
-            A::new::<submod::B>(submod::B {})
+            Self::new::<submod::B>(submod::B {})
         }
     }
 }
diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs
index 85606049774..bbe92c9e338 100644
--- a/tests/ui/use_self.rs
+++ b/tests/ui/use_self.rs
@@ -3,7 +3,7 @@
 
 #![warn(clippy::use_self)]
 #![allow(dead_code)]
-#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms)]
+#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms, clippy::from_over_into)]
 
 fn main() {}
 
@@ -15,15 +15,12 @@ mod use_self {
             Foo {}
         }
         fn test() -> Foo {
-            // FIXME: applicable here
             Foo::new()
         }
     }
 
     impl Default for Foo {
-        // FIXME: applicable here
         fn default() -> Foo {
-            // FIXME: applicable here
             Foo::new()
         }
     }
@@ -74,13 +71,12 @@ mod lifetimes {
 
 mod issue2894 {
     trait IntoBytes {
-        #[allow(clippy::wrong_self_convention)]
-        fn into_bytes(&self) -> Vec<u8>;
+        fn to_bytes(&self) -> Vec<u8>;
     }
 
     // This should not be linted
     impl IntoBytes for u8 {
-        fn into_bytes(&self) -> Vec<u8> {
+        fn to_bytes(&self) -> Vec<u8> {
             vec![*self]
         }
     }
@@ -90,10 +86,6 @@ mod existential {
     struct Foo;
 
     impl Foo {
-        // FIXME:
-        // TyKind::Def (used for `impl Trait` types) does not include type parameters yet.
-        // See documentation in rustc_hir::hir::TyKind.
-        // The hir tree walk stops at `impl Iterator` level and does not inspect &Foo.
         fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
             foos.iter()
         }
@@ -215,9 +207,7 @@ mod rustfix {
         fn fun_1() {}
 
         fn fun_2() {
-            // FIXME: applicable here
             nested::A::fun_1();
-            // FIXME: applicable here
             nested::A::A;
 
             nested::A {};
@@ -239,7 +229,6 @@ mod issue3567 {
 
     impl Test for TestStruct {
         fn test() -> TestStruct {
-            // FIXME: applicable here
             TestStruct::from_something()
         }
     }
@@ -254,13 +243,11 @@ mod paths_created_by_lowering {
         const A: usize = 0;
         const B: usize = 1;
 
-        // FIXME: applicable here
         async fn g() -> S {
             S {}
         }
 
         fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
-            // FIXME: applicable here twice
             &p[S::A..S::B]
         }
     }
@@ -381,7 +368,6 @@ mod issue4305 {
 
     impl<T: Foo> From<T> for Box<dyn Foo> {
         fn from(t: T) -> Self {
-            // FIXME: applicable here
             Box::new(t)
         }
     }
@@ -461,7 +447,6 @@ mod nested_paths {
 
     impl A<submod::C> {
         fn test() -> Self {
-            // FIXME: applicable here
             A::new::<submod::B>(submod::B {})
         }
     }
diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr
index 4d213316cf5..d86453eb2f0 100644
--- a/tests/ui/use_self.stderr
+++ b/tests/ui/use_self.stderr
@@ -1,16 +1,16 @@
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:15:13
+  --> $DIR/use_self.rs:14:21
    |
-LL |             Foo {}
-   |             ^^^ help: use the applicable keyword: `Self`
+LL |         fn new() -> Foo {
+   |                     ^^^ help: use the applicable keyword: `Self`
    |
    = note: `-D clippy::use-self` implied by `-D warnings`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:14:21
+  --> $DIR/use_self.rs:15:13
    |
-LL |         fn new() -> Foo {
-   |                     ^^^ help: use the applicable keyword: `Self`
+LL |             Foo {}
+   |             ^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
   --> $DIR/use_self.rs:17:22
@@ -19,22 +19,46 @@ LL |         fn test() -> Foo {
    |                      ^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:96:24
+  --> $DIR/use_self.rs:18:13
+   |
+LL |             Foo::new()
+   |             ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:23:25
+   |
+LL |         fn default() -> Foo {
+   |                         ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:24:13
+   |
+LL |             Foo::new()
+   |             ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:89:24
    |
 LL |         fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
    |                        ^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:111:13
+  --> $DIR/use_self.rs:89:55
+   |
+LL |         fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
+   |                                                       ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:104:13
    |
 LL |             TS(0)
    |             ^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:120:17
+  --> $DIR/use_self.rs:112:25
    |
-LL |                 Foo {}
-   |                 ^^^ help: use the applicable keyword: `Self`
+LL |             fn new() -> Foo {
+   |                         ^^^ help: use the applicable keyword: `Self`
 ...
 LL |         use_self_expand!(); // Should lint in local macros
    |         ------------------- in this macro invocation
@@ -42,10 +66,10 @@ LL |         use_self_expand!(); // Should lint in local macros
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:119:25
+  --> $DIR/use_self.rs:113:17
    |
-LL |             fn new() -> Foo {
-   |                         ^^^ help: use the applicable keyword: `Self`
+LL |                 Foo {}
+   |                 ^^^ help: use the applicable keyword: `Self`
 ...
 LL |         use_self_expand!(); // Should lint in local macros
    |         ------------------- in this macro invocation
@@ -53,82 +77,124 @@ LL |         use_self_expand!(); // Should lint in local macros
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:144:21
-   |
-LL |                     Bar { foo: Foo {} }
-   |                     ^^^ help: use the applicable keyword: `Self`
-
-error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:143:29
+  --> $DIR/use_self.rs:136:29
    |
 LL |                 fn bar() -> Bar {
    |                             ^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:156:13
+  --> $DIR/use_self.rs:137:21
    |
-LL |             Foo {}
-   |             ^^^ help: use the applicable keyword: `Self`
+LL |                     Bar { foo: Foo {} }
+   |                     ^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:155:21
+  --> $DIR/use_self.rs:148:21
    |
 LL |         fn baz() -> Foo {
    |                     ^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:173:21
+  --> $DIR/use_self.rs:149:13
+   |
+LL |             Foo {}
+   |             ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:166:21
    |
 LL |             let _ = Enum::B(42);
    |                     ^^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:174:21
+  --> $DIR/use_self.rs:167:21
    |
 LL |             let _ = Enum::C { field: true };
    |                     ^^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:175:21
+  --> $DIR/use_self.rs:168:21
    |
 LL |             let _ = Enum::A;
    |                     ^^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:222:13
+  --> $DIR/use_self.rs:210:13
+   |
+LL |             nested::A::fun_1();
+   |             ^^^^^^^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:211:13
+   |
+LL |             nested::A::A;
+   |             ^^^^^^^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:213:13
    |
 LL |             nested::A {};
    |             ^^^^^^^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:258:13
+  --> $DIR/use_self.rs:232:13
+   |
+LL |             TestStruct::from_something()
+   |             ^^^^^^^^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:246:25
+   |
+LL |         async fn g() -> S {
+   |                         ^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:247:13
    |
 LL |             S {}
    |             ^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:287:13
+  --> $DIR/use_self.rs:251:16
    |
-LL |             Foo { value }
-   |             ^^^ help: use the applicable keyword: `Self`
+LL |             &p[S::A..S::B]
+   |                ^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:251:22
+   |
+LL |             &p[S::A..S::B]
+   |                      ^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:286:29
+  --> $DIR/use_self.rs:274:29
    |
 LL |         fn foo(value: T) -> Foo<T> {
    |                             ^^^^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:324:21
+  --> $DIR/use_self.rs:275:13
+   |
+LL |             Foo { value }
+   |             ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:312:21
    |
 LL |         type From = T::From;
    |                     ^^^^^^^ help: use the applicable keyword: `Self`
 
 error: unnecessary structure name repetition
-  --> $DIR/use_self.rs:325:19
+  --> $DIR/use_self.rs:313:19
    |
 LL |         type To = T::To;
    |                   ^^^^^ help: use the applicable keyword: `Self`
 
-error: aborting due to 20 previous errors
+error: unnecessary structure name repetition
+  --> $DIR/use_self.rs:450:13
+   |
+LL |             A::new::<submod::B>(submod::B {})
+   |             ^ help: use the applicable keyword: `Self`
+
+error: aborting due to 31 previous errors
 
diff --git a/tests/ui/use_self_trait.fixed b/tests/ui/use_self_trait.fixed
index 680a0623839..9bcd692fb35 100644
--- a/tests/ui/use_self_trait.fixed
+++ b/tests/ui/use_self_trait.fixed
@@ -18,35 +18,36 @@ trait SelfTrait {
 struct Bad;
 
 impl SelfTrait for Bad {
-    fn refs(p1: &Bad) -> &Bad {
+    fn refs(p1: &Self) -> &Self {
         p1
     }
 
-    fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad {
+    fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self {
         p1
     }
 
-    fn mut_refs(p1: &mut Bad) -> &mut Bad {
+    fn mut_refs(p1: &mut Self) -> &mut Self {
         p1
     }
 
-    fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {}
+    fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
 
-    fn vals(_: Bad) -> Bad {
-        Bad::default()
+    fn vals(_: Self) -> Self {
+        Self::default()
     }
 }
 
 impl Mul for Bad {
     type Output = Self;
 
-    fn mul(self, rhs: Bad) -> Bad {
+    fn mul(self, rhs: Self) -> Self {
         rhs
     }
 }
 
 impl Clone for Bad {
     fn clone(&self) -> Self {
+        // FIXME: applicable here
         Bad
     }
 }
diff --git a/tests/ui/use_self_trait.rs b/tests/ui/use_self_trait.rs
index 70667b9797e..de305d40f33 100644
--- a/tests/ui/use_self_trait.rs
+++ b/tests/ui/use_self_trait.rs
@@ -47,6 +47,7 @@ impl Mul for Bad {
 
 impl Clone for Bad {
     fn clone(&self) -> Self {
+        // FIXME: applicable here
         Bad
     }
 }
diff --git a/tests/ui/use_self_trait.stderr b/tests/ui/use_self_trait.stderr
index 5409ccedf85..55af3ff2a93 100644
--- a/tests/ui/use_self_trait.stderr
+++ b/tests/ui/use_self_trait.stderr
@@ -1,10 +1,88 @@
 error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:21:18
+   |
+LL |     fn refs(p1: &Bad) -> &Bad {
+   |                  ^^^ help: use the applicable keyword: `Self`
+   |
+   = note: `-D clippy::use-self` implied by `-D warnings`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:21:27
+   |
+LL |     fn refs(p1: &Bad) -> &Bad {
+   |                           ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:25:33
+   |
+LL |     fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad {
+   |                                 ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:25:49
+   |
+LL |     fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad {
+   |                                                 ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:29:26
+   |
+LL |     fn mut_refs(p1: &mut Bad) -> &mut Bad {
+   |                          ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:29:39
+   |
+LL |     fn mut_refs(p1: &mut Bad) -> &mut Bad {
+   |                                       ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:33:24
+   |
+LL |     fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {}
+   |                        ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:33:42
+   |
+LL |     fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {}
+   |                                          ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:35:16
+   |
+LL |     fn vals(_: Bad) -> Bad {
+   |                ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:35:24
+   |
+LL |     fn vals(_: Bad) -> Bad {
+   |                        ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:36:9
+   |
+LL |         Bad::default()
+   |         ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
   --> $DIR/use_self_trait.rs:41:19
    |
 LL |     type Output = Bad;
    |                   ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:43:23
    |
-   = note: `-D clippy::use-self` implied by `-D warnings`
+LL |     fn mul(self, rhs: Bad) -> Bad {
+   |                       ^^^ help: use the applicable keyword: `Self`
+
+error: unnecessary structure name repetition
+  --> $DIR/use_self_trait.rs:43:31
+   |
+LL |     fn mul(self, rhs: Bad) -> Bad {
+   |                               ^^^ help: use the applicable keyword: `Self`
 
-error: aborting due to previous error
+error: aborting due to 14 previous errors