]> git.lizzy.rs Git - rust.git/blob - tests/ui/manual_async_fn.rs
bd5f9d1cf5f2ee62b4af834646760518cb568ac5
[rust.git] / 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 { 42 }
40     }
41
42     fn meth_fut(&self) -> impl Future<Output = i32> {
43         async { 42 }
44     }
45
46     fn empty_fut(&self) -> impl Future<Output = ()> {
47         async {}
48     }
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() {}