fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.5 KiB78 linesraw
1#![feature(lint_reasons)]
2#![feature(async_closure)]
3#![warn(clippy::async_yields_async)]
4#![allow(clippy::redundant_async_block)]
5
6use core::future::Future;
7use core::pin::Pin;
8use core::task::{Context, Poll};
9
10struct CustomFutureType;
11
12impl Future for CustomFutureType {
13    type Output = u8;
14
15    fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
16        Poll::Ready(3)
17    }
18}
19
20fn custom_future_type_ctor() -> CustomFutureType {
21    CustomFutureType
22}
23
24async fn f() -> CustomFutureType {
25    // Don't warn for functions since you have to explicitly declare their
26    // return types.
27    CustomFutureType
28}
29
30#[rustfmt::skip]
31fn main() {
32    let _f = {
33        3
34    };
35    let _g = async {
36        3
37    };
38    let _h = async {
39        async {
40            3
41        }.await
42    };
43    let _i = async {
44        CustomFutureType.await
45    };
46    let _i = async || {
47        3
48    };
49    let _j = async || {
50        async {
51            3
52        }.await
53    };
54    let _k = async || {
55        CustomFutureType.await
56    };
57    let _l = async || CustomFutureType.await;
58    let _m = async || {
59        println!("I'm bored");
60        // Some more stuff
61
62        // Finally something to await
63        CustomFutureType.await
64    };
65    let _n = async || custom_future_type_ctor();
66    let _o = async || f();
67}
68
69#[rustfmt::skip]
70#[allow(dead_code)]
71fn check_expect_suppression() {
72    #[expect(clippy::async_yields_async)]
73    let _j = async || {
74        async {
75            3
76        }
77    };
78}