]> git.lizzy.rs Git - rust.git/blob - tests/ui/manual_async_fn.fixed
iterate List by value
[rust.git] / tests / ui / manual_async_fn.fixed
1 // run-rustfix
2 // edition:2018
3 #![warn(clippy::manual_async_fn)]
4 #![allow(unused)]
5
6 use std::future::Future;
7
8 async fn fut() -> i32 { 42 }
9
10 async fn empty_fut()  {}
11
12 async fn core_fut() -> i32 { 42 }
13
14 // should be ignored
15 fn has_other_stmts() -> impl core::future::Future<Output = i32> {
16     let _ = 42;
17     async move { 42 }
18 }
19
20 // should be ignored
21 fn not_fut() -> i32 {
22     42
23 }
24
25 // should be ignored
26 async fn already_async() -> impl Future<Output = i32> {
27     async { 42 }
28 }
29
30 struct S {}
31 impl S {
32     async fn inh_fut() -> i32 {
33         // NOTE: this code is here just to check that the identation is correct in the suggested fix
34         let a = 42;
35         let b = 21;
36         if a < b {
37             let c = 21;
38             let d = 42;
39             if c < d {
40                 let _ = 42;
41             }
42         }
43         42
44     }
45
46     async fn meth_fut(&self) -> i32 { 42 }
47
48     async fn empty_fut(&self)  {}
49
50     // should be ignored
51     fn not_fut(&self) -> i32 {
52         42
53     }
54
55     // should be ignored
56     fn has_other_stmts() -> impl core::future::Future<Output = i32> {
57         let _ = 42;
58         async move { 42 }
59     }
60
61     // should be ignored
62     async fn already_async(&self) -> impl Future<Output = i32> {
63         async { 42 }
64     }
65 }
66
67 fn main() {}