]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/let_return.rs
iterate List by value
[rust.git] / tests / ui / let_return.rs
index 40052f86dd53fe16b62622a8dbe1bdc104db1ab8..23645d48fe79913acf7f7c856ca5fa846ee2ee72 100644 (file)
@@ -45,4 +45,26 @@ fn test_nowarn_5(x: i16) -> u16 {
     x
 }
 
+// False positive example
+trait Decode {
+    fn decode<D: std::io::Read>(d: D) -> Result<Self, ()>
+    where
+        Self: Sized;
+}
+
+macro_rules! tuple_encode {
+    ($($x:ident),*) => (
+        impl<$($x: Decode),*> Decode for ($($x),*) {
+            #[inline]
+            #[allow(non_snake_case)]
+            fn decode<D: std::io::Read>(mut d: D) -> Result<Self, ()> {
+                // Shouldn't trigger lint
+                Ok(($({let $x = Decode::decode(&mut d)?; $x }),*))
+            }
+        }
+    );
+}
+
+tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7);
+
 fn main() {}