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