]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/async_yields_async.fixed
Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup
[rust.git] / src / tools / clippy / tests / ui / async_yields_async.fixed
1 // run-rustfix
2 // edition:2018
3
4 #![feature(async_closure)]
5 #![warn(clippy::async_yields_async)]
6
7 use core::future::Future;
8 use core::pin::Pin;
9 use core::task::{Context, Poll};
10
11 struct CustomFutureType;
12
13 impl Future for CustomFutureType {
14     type Output = u8;
15
16     fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
17         Poll::Ready(3)
18     }
19 }
20
21 fn custom_future_type_ctor() -> CustomFutureType {
22     CustomFutureType
23 }
24
25 async fn f() -> CustomFutureType {
26     // Don't warn for functions since you have to explicitly declare their
27     // return types.
28     CustomFutureType
29 }
30
31 #[rustfmt::skip]
32 fn main() {
33     let _f = {
34         3
35     };
36     let _g = async {
37         3
38     };
39     let _h = async {
40         async {
41             3
42         }.await
43     };
44     let _i = async {
45         CustomFutureType.await
46     };
47     let _i = async || {
48         3
49     };
50     let _j = async || {
51         async {
52             3
53         }.await
54     };
55     let _k = async || {
56         CustomFutureType.await
57     };
58     let _l = async || CustomFutureType.await;
59     let _m = async || {
60         println!("I'm bored");
61         // Some more stuff
62
63         // Finally something to await
64         CustomFutureType.await
65     };
66     let _n = async || custom_future_type_ctor();
67     let _o = async || f();
68 }