]>
Commit | Line | Data |
---|---|---|
48663c56 XL |
1 | // edition:2018 |
2 | ||
48663c56 XL |
3 | async fn bar() -> Result<(), ()> { |
4 | Ok(()) | |
5 | } | |
6 | ||
7 | async fn foo1() -> Result<(), ()> { | |
8 | let _ = await bar(); //~ ERROR incorrect use of `await` | |
9 | Ok(()) | |
10 | } | |
11 | async fn foo2() -> Result<(), ()> { | |
12 | let _ = await? bar(); //~ ERROR incorrect use of `await` | |
13 | Ok(()) | |
14 | } | |
15 | async fn foo3() -> Result<(), ()> { | |
16 | let _ = await bar()?; //~ ERROR incorrect use of `await` | |
1b1a35ee | 17 | //~^ ERROR the `?` operator can only be applied to values that implement `Try` |
48663c56 XL |
18 | Ok(()) |
19 | } | |
20 | async fn foo21() -> Result<(), ()> { | |
21 | let _ = await { bar() }; //~ ERROR incorrect use of `await` | |
22 | Ok(()) | |
23 | } | |
24 | async fn foo22() -> Result<(), ()> { | |
25 | let _ = await(bar()); //~ ERROR incorrect use of `await` | |
26 | Ok(()) | |
27 | } | |
28 | async fn foo23() -> Result<(), ()> { | |
29 | let _ = await { bar() }?; //~ ERROR incorrect use of `await` | |
30 | Ok(()) | |
31 | } | |
32 | async fn foo4() -> Result<(), ()> { | |
33 | let _ = (await bar())?; //~ ERROR incorrect use of `await` | |
34 | Ok(()) | |
35 | } | |
36 | async fn foo5() -> Result<(), ()> { | |
37 | let _ = bar().await(); //~ ERROR incorrect use of `await` | |
38 | Ok(()) | |
39 | } | |
40 | async fn foo6() -> Result<(), ()> { | |
41 | let _ = bar().await()?; //~ ERROR incorrect use of `await` | |
42 | Ok(()) | |
43 | } | |
44 | async fn foo7() -> Result<(), ()> { | |
45 | let _ = bar().await; // OK | |
46 | Ok(()) | |
47 | } | |
48 | async fn foo8() -> Result<(), ()> { | |
49 | let _ = bar().await?; // OK | |
50 | Ok(()) | |
51 | } | |
52 | fn foo9() -> Result<(), ()> { | |
53 | let _ = await bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks | |
54 | //~^ ERROR incorrect use of `await` | |
55 | Ok(()) | |
56 | } | |
57 | fn foo10() -> Result<(), ()> { | |
58 | let _ = await? bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks | |
59 | //~^ ERROR incorrect use of `await` | |
60 | Ok(()) | |
61 | } | |
62 | fn foo11() -> Result<(), ()> { | |
63 | let _ = await bar()?; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
64 | //~^ ERROR incorrect use of `await` | |
1b1a35ee | 65 | //~| ERROR the `?` operator can only be applied to values that implement `Try` |
48663c56 XL |
66 | Ok(()) |
67 | } | |
68 | fn foo12() -> Result<(), ()> { | |
69 | let _ = (await bar())?; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
70 | //~^ ERROR incorrect use of `await` | |
71 | Ok(()) | |
72 | } | |
73 | fn foo13() -> Result<(), ()> { | |
74 | let _ = bar().await(); //~ ERROR `await` is only allowed inside `async` functions and blocks | |
75 | //~^ ERROR incorrect use of `await` | |
76 | Ok(()) | |
77 | } | |
78 | fn foo14() -> Result<(), ()> { | |
79 | let _ = bar().await()?; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
80 | //~^ ERROR incorrect use of `await` | |
81 | Ok(()) | |
82 | } | |
83 | fn foo15() -> Result<(), ()> { | |
84 | let _ = bar().await; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
85 | Ok(()) | |
86 | } | |
87 | fn foo16() -> Result<(), ()> { | |
88 | let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
89 | Ok(()) | |
90 | } | |
91 | fn foo24() -> Result<(), ()> { | |
92 | fn foo() -> Result<(), ()> { | |
93 | let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
94 | Ok(()) | |
95 | } | |
96 | foo() | |
97 | } | |
98 | fn foo25() -> Result<(), ()> { | |
99 | let foo = || { | |
100 | let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks | |
101 | Ok(()) | |
102 | }; | |
103 | foo() | |
104 | } | |
105 | ||
416331ca XL |
106 | async fn foo26() -> Result<(), ()> { |
107 | let _ = await!(bar()); //~ ERROR incorrect use of `await` | |
108 | Ok(()) | |
109 | } | |
110 | async fn foo27() -> Result<(), ()> { | |
111 | let _ = await!(bar())?; //~ ERROR incorrect use of `await` | |
112 | Ok(()) | |
113 | } | |
114 | fn foo28() -> Result<(), ()> { | |
115 | fn foo() -> Result<(), ()> { | |
116 | let _ = await!(bar())?; //~ ERROR incorrect use of `await` | |
117 | //~^ ERROR `await` is only allowed inside `async` functions | |
118 | Ok(()) | |
119 | } | |
120 | foo() | |
121 | } | |
122 | fn foo29() -> Result<(), ()> { | |
123 | let foo = || { | |
124 | let _ = await!(bar())?; //~ ERROR incorrect use of `await` | |
125 | //~^ ERROR `await` is only allowed inside `async` functions | |
126 | Ok(()) | |
127 | }; | |
128 | foo() | |
129 | } | |
130 | ||
48663c56 XL |
131 | fn main() { |
132 | match await { await => () } | |
133 | //~^ ERROR expected expression, found `=>` | |
134 | //~| ERROR incorrect use of `await` | |
135 | } //~ ERROR expected one of `.`, `?`, `{`, or an operator, found `}` |