]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/needless_lifetimes.rs
Auto merge of #68717 - petrochenkov:stabexpat, r=varkor
[rust.git] / tests / ui / needless_lifetimes.rs
index e2d680ceaeb1938b1b996a84df7be2e068abe937..913cd004f19f4bd70941f49127930ec902573669 100644 (file)
@@ -1,5 +1,5 @@
 #![warn(clippy::needless_lifetimes)]
-#![allow(dead_code, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)]
+#![allow(dead_code, clippy::needless_pass_by_value)]
 
 fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
 
@@ -166,16 +166,16 @@ fn struct_with_lt4<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str {
 
 trait WithLifetime<'a> {}
 
-type WithLifetimeAlias<'a> = WithLifetime<'a>;
+type WithLifetimeAlias<'a> = dyn WithLifetime<'a>;
 
 // Should not warn because it won't build without the lifetime.
-fn trait_obj_elided<'a>(_arg: &'a WithLifetime) -> &'a str {
+fn trait_obj_elided<'a>(_arg: &'a dyn WithLifetime) -> &'a str {
     unimplemented!()
 }
 
 // Should warn because there is no lifetime on `Drop`, so this would be
 // unambiguous if we elided the lifetime.
-fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str {
+fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
     unimplemented!()
 }
 
@@ -226,7 +226,7 @@ struct Test {
 }
 
 impl Test {
-    fn iter<'a>(&'a self) -> Box<Iterator<Item = usize> + 'a> {
+    fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = usize> + 'a> {
         unimplemented!()
     }
 }
@@ -248,4 +248,15 @@ fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
     unimplemented!()
 }
 
+// Make sure we still warn on implementations
+mod issue4291 {
+    trait BadTrait {
+        fn needless_lt<'a>(x: &'a u8) {}
+    }
+
+    impl BadTrait for () {
+        fn needless_lt<'a>(_x: &'a u8) {}
+    }
+}
+
 fn main() {}