]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/new_ret_no_self.rs
iterate List by value
[rust.git] / tests / ui / new_ret_no_self.rs
index bed43f550f218539dd2d7b5868a9d63b2b8fc3e2..2c2d1e275893fae41e3965c9c4568f2afad8c6e8 100644 (file)
@@ -1,7 +1,7 @@
 #![warn(clippy::new_ret_no_self)]
-#![allow(dead_code, clippy::trivially_copy_pass_by_ref)]
+#![allow(dead_code)]
 
-fn main(){}
+fn main() {}
 
 trait R {
     type Item;
@@ -96,82 +96,117 @@ pub fn new(_: String) -> u32 {
 
 impl TupleReturnerOk {
     // should not trigger lint
-    pub fn new() -> (Self, u32) { unimplemented!(); }
+    pub fn new() -> (Self, u32) {
+        unimplemented!();
+    }
 }
 
 struct TupleReturnerOk2;
 
 impl TupleReturnerOk2 {
     // should not trigger lint (it doesn't matter which element in the tuple is Self)
-    pub fn new() -> (u32, Self) { unimplemented!(); }
+    pub fn new() -> (u32, Self) {
+        unimplemented!();
+    }
 }
 
 struct TupleReturnerOk3;
 
 impl TupleReturnerOk3 {
     // should not trigger lint (tuple can contain multiple Self)
-    pub fn new() -> (Self, Self) { unimplemented!(); }
+    pub fn new() -> (Self, Self) {
+        unimplemented!();
+    }
 }
 
 struct TupleReturnerBad;
 
 impl TupleReturnerBad {
     // should trigger lint
-    pub fn new() -> (u32, u32) { unimplemented!(); }
+    pub fn new() -> (u32, u32) {
+        unimplemented!();
+    }
 }
 
 struct MutPointerReturnerOk;
 
 impl MutPointerReturnerOk {
     // should not trigger lint
-    pub fn new() -> *mut Self { unimplemented!(); }
+    pub fn new() -> *mut Self {
+        unimplemented!();
+    }
 }
 
 struct MutPointerReturnerOk2;
 
 impl MutPointerReturnerOk2 {
     // should not trigger lint
-    pub fn new() -> *const Self { unimplemented!(); }
+    pub fn new() -> *const Self {
+        unimplemented!();
+    }
 }
 
 struct MutPointerReturnerBad;
 
 impl MutPointerReturnerBad {
     // should trigger lint
-    pub fn new() -> *mut V { unimplemented!(); }
+    pub fn new() -> *mut V {
+        unimplemented!();
+    }
 }
 
 struct GenericReturnerOk;
 
 impl GenericReturnerOk {
     // should not trigger lint
-    pub fn new() -> Option<Self> { unimplemented!(); }
+    pub fn new() -> Option<Self> {
+        unimplemented!();
+    }
 }
 
 struct GenericReturnerBad;
 
 impl GenericReturnerBad {
     // should trigger lint
-    pub fn new() -> Option<u32> { unimplemented!(); }
+    pub fn new() -> Option<u32> {
+        unimplemented!();
+    }
 }
 
 struct NestedReturnerOk;
 
 impl NestedReturnerOk {
     // should not trigger lint
-    pub fn new() -> (Option<Self>, u32) { unimplemented!(); }
+    pub fn new() -> (Option<Self>, u32) {
+        unimplemented!();
+    }
 }
 
 struct NestedReturnerOk2;
 
 impl NestedReturnerOk2 {
     // should not trigger lint
-    pub fn new() -> ((Self, u32), u32) { unimplemented!(); }
+    pub fn new() -> ((Self, u32), u32) {
+        unimplemented!();
+    }
 }
 
 struct NestedReturnerOk3;
 
 impl NestedReturnerOk3 {
     // should not trigger lint
-    pub fn new() -> Option<(Self, u32)> { unimplemented!(); }
+    pub fn new() -> Option<(Self, u32)> {
+        unimplemented!();
+    }
+}
+
+struct WithLifetime<'a> {
+    cat: &'a str,
+}
+
+impl<'a> WithLifetime<'a> {
+    // should not trigger the lint, because the lifetimes are different
+    pub fn new<'b: 'a>(s: &'b str) -> WithLifetime<'b> {
+        unimplemented!();
+    }
 }