]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/unused_async.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / unused_async.rs
index 2a3a506a57b1437310918767ad1fa55ab0987052..4ca7f29b34cd085af07587e6b755a8ee3855dbef 100644 (file)
@@ -1,5 +1,8 @@
 #![warn(clippy::unused_async)]
 
+use std::future::Future;
+use std::pin::Pin;
+
 async fn foo() -> i32 {
     4
 }
@@ -8,6 +11,37 @@ async fn bar() -> i32 {
     foo().await
 }
 
+struct S;
+
+impl S {
+    async fn unused(&self) -> i32 {
+        1
+    }
+
+    async fn used(&self) -> i32 {
+        self.unused().await
+    }
+}
+
+trait AsyncTrait {
+    fn trait_method() -> Pin<Box<dyn Future<Output = i32>>>;
+}
+
+macro_rules! async_trait_impl {
+    () => {
+        impl AsyncTrait for S {
+            fn trait_method() -> Pin<Box<dyn Future<Output = i32>>> {
+                async fn unused() -> i32 {
+                    5
+                }
+
+                Box::pin(unused())
+            }
+        }
+    };
+}
+async_trait_impl!();
+
 fn main() {
     foo();
     bar();