]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/unused_async.rs
Rollup merge of #102764 - compiler-errors:issue-102762, r=jackh726
[rust.git] / src / tools / clippy / tests / ui / unused_async.rs
1 #![warn(clippy::unused_async)]
2
3 use std::future::Future;
4 use std::pin::Pin;
5
6 async fn foo() -> i32 {
7     4
8 }
9
10 async fn bar() -> i32 {
11     foo().await
12 }
13
14 struct S;
15
16 impl S {
17     async fn unused(&self) -> i32 {
18         1
19     }
20
21     async fn used(&self) -> i32 {
22         self.unused().await
23     }
24 }
25
26 trait AsyncTrait {
27     fn trait_method() -> Pin<Box<dyn Future<Output = i32>>>;
28 }
29
30 macro_rules! async_trait_impl {
31     () => {
32         impl AsyncTrait for S {
33             fn trait_method() -> Pin<Box<dyn Future<Output = i32>>> {
34                 async fn unused() -> i32 {
35                     5
36                 }
37
38                 Box::pin(unused())
39             }
40         }
41     };
42 }
43 async_trait_impl!();
44
45 fn main() {
46     foo();
47     bar();
48 }