]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/extra_unused_lifetimes.rs
`assertions_on_result_states` fix suggestion when `assert!` not in a statement
[rust.git] / tests / ui / extra_unused_lifetimes.rs
index 69dc2f7965e10da7d182df5e6f0af4c6d5352a27..d6631e01290009feee27ded294e324031b763be7 100644 (file)
@@ -1,3 +1,5 @@
+// aux-build:proc_macro_derive.rs
+
 #![allow(
     unused,
     dead_code,
@@ -7,6 +9,9 @@
 )]
 #![warn(clippy::extra_unused_lifetimes)]
 
+#[macro_use]
+extern crate proc_macro_derive;
+
 fn empty() {}
 
 fn used_lt<'a>(x: &'a u8) {}
@@ -88,4 +93,37 @@ pub fn something<'c>() -> Self {
     }
 }
 
+// https://github.com/rust-lang/rust-clippy/pull/8737#pullrequestreview-951268213
+mod first_case {
+    use serde::de::Visitor;
+    pub trait Expected {
+        fn fmt(&self, formatter: &mut std::fmt::Formatter);
+    }
+
+    impl<'de, T> Expected for T
+    where
+        T: Visitor<'de>,
+    {
+        fn fmt(&self, formatter: &mut std::fmt::Formatter) {}
+    }
+}
+
+// https://github.com/rust-lang/rust-clippy/pull/8737#pullrequestreview-951268213
+mod second_case {
+    pub trait Source {
+        fn hey();
+    }
+
+    impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
+        fn hey() {}
+    }
+}
+
+// Should not lint
+#[derive(ExtraLifetimeDerive)]
+struct Human<'a> {
+    pub bones: i32,
+    pub name: &'a str,
+}
+
 fn main() {}