]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui-toml / await_holding_invalid_type / await_holding_invalid_type.rs
1 #![warn(clippy::await_holding_invalid_type)]
2 use std::net::Ipv4Addr;
3
4 async fn bad() -> u32 {
5 let _x = String::from("hello");
6 baz().await
7 }
8
9 async fn bad_reason() -> u32 {
10 let _x = Ipv4Addr::new(127, 0, 0, 1);
11 baz().await
12 }
13
14 async fn good() -> u32 {
15 {
16 let _x = String::from("hi!");
17 let _y = Ipv4Addr::new(127, 0, 0, 1);
18 }
19 baz().await;
20 let _x = String::from("hi!");
21 47
22 }
23
24 async fn baz() -> u32 {
25 42
26 }
27
28 #[allow(clippy::manual_async_fn)]
29 fn block_bad() -> impl std::future::Future<Output = u32> {
30 async move {
31 let _x = String::from("hi!");
32 baz().await
33 }
34 }
35
36 fn main() {
37 good();
38 bad();
39 bad_reason();
40 block_bad();
41 }