]>
Commit | Line | Data |
---|---|---|
dc9dc135 | 1 | // edition:2018 |
dc9dc135 | 2 | |
dc9dc135 XL |
3 | fn take_u32(_x: u32) {} |
4 | ||
5 | async fn make_u32() -> u32 { | |
6 | 22 | |
7 | } | |
8 | ||
9 | #[allow(unused)] | |
10 | async fn suggest_await_in_async_fn() { | |
11 | let x = make_u32(); | |
12 | take_u32(x) | |
13 | //~^ ERROR mismatched types [E0308] | |
29967ef6 XL |
14 | //~| HELP consider `await`ing on the `Future` |
15 | //~| SUGGESTION .await | |
dc9dc135 XL |
16 | } |
17 | ||
60c5eb7d XL |
18 | async fn dummy() {} |
19 | ||
20 | #[allow(unused)] | |
21 | async fn suggest_await_in_async_fn_return() { | |
22 | dummy() | |
23 | //~^ ERROR mismatched types [E0308] | |
6a06907d | 24 | //~| HELP consider using a semicolon here |
29967ef6 XL |
25 | //~| HELP consider `await`ing on the `Future` |
26 | //~| SUGGESTION .await | |
60c5eb7d XL |
27 | } |
28 | ||
3c0e092e XL |
29 | #[allow(unused)] |
30 | async fn suggest_await_on_if() { | |
31 | let _x = if true { | |
32 | dummy() | |
33 | //~^ HELP consider `await`ing on the `Future` | |
34 | } else { | |
35 | dummy().await | |
36 | //~^ ERROR `if` and `else` have incompatible types [E0308] | |
37 | }; | |
38 | } | |
39 | ||
40 | #[allow(unused)] | |
41 | async fn suggest_await_on_previous_match_arms() { | |
42 | let _x = match 0usize { | |
43 | 0 => dummy(), //~ HELP consider `await`ing on the `Future` | |
44 | 1 => dummy(), | |
45 | 2 => dummy().await, | |
46 | //~^ `match` arms have incompatible types [E0308] | |
47 | }; | |
48 | } | |
49 | ||
50 | #[allow(unused)] | |
51 | async fn suggest_await_on_match_expr() { | |
52 | let _x = match dummy() { //~ HELP consider `await`ing on the `Future` | |
53 | () => {} //~ ERROR mismatched types [E0308] | |
54 | }; | |
55 | } | |
56 | ||
57 | async fn dummy_result() -> Result<(), ()> { | |
58 | Ok(()) | |
59 | } | |
60 | ||
61 | #[allow(unused)] | |
62 | async fn suggest_await_in_generic_pattern() { | |
63 | match dummy_result() { | |
64 | //~^ HELP consider `await`ing on the `Future` | |
65 | //~| HELP consider `await`ing on the `Future` | |
66 | //~| SUGGESTION .await | |
67 | Ok(_) => {} | |
68 | //~^ ERROR mismatched types [E0308] | |
69 | Err(_) => {} | |
70 | //~^ ERROR mismatched types [E0308] | |
71 | } | |
72 | } | |
73 | ||
dc9dc135 | 74 | fn main() {} |