summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs
blob: fbef5c4564b1bb6444016ec07b0ca11ca91bb5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#![warn(clippy::await_holding_invalid_type)]
use std::net::Ipv4Addr;

async fn bad() -> u32 {
    let _x = String::from("hello");
    baz().await
}

async fn bad_reason() -> u32 {
    let _x = Ipv4Addr::new(127, 0, 0, 1);
    baz().await
}

async fn good() -> u32 {
    {
        let _x = String::from("hi!");
        let _y = Ipv4Addr::new(127, 0, 0, 1);
    }
    baz().await;
    let _x = String::from("hi!");
    47
}

async fn baz() -> u32 {
    42
}

#[allow(clippy::manual_async_fn)]
fn block_bad() -> impl std::future::Future<Output = u32> {
    async move {
        let _x = String::from("hi!");
        baz().await
    }
}

fn main() {
    good();
    bad();
    bad_reason();
    block_bad();
}