]> git.proxmox.com Git - rustc.git/blame - src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / async-await / await-keyword / incorrect-syntax-suggestions.rs
CommitLineData
48663c56
XL
1// edition:2018
2
48663c56
XL
3async fn bar() -> Result<(), ()> {
4 Ok(())
5}
6
7async fn foo1() -> Result<(), ()> {
8 let _ = await bar(); //~ ERROR incorrect use of `await`
9 Ok(())
10}
11async fn foo2() -> Result<(), ()> {
12 let _ = await? bar(); //~ ERROR incorrect use of `await`
13 Ok(())
14}
15async 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}
20async fn foo21() -> Result<(), ()> {
21 let _ = await { bar() }; //~ ERROR incorrect use of `await`
22 Ok(())
23}
24async fn foo22() -> Result<(), ()> {
25 let _ = await(bar()); //~ ERROR incorrect use of `await`
26 Ok(())
27}
28async fn foo23() -> Result<(), ()> {
29 let _ = await { bar() }?; //~ ERROR incorrect use of `await`
30 Ok(())
31}
32async fn foo4() -> Result<(), ()> {
33 let _ = (await bar())?; //~ ERROR incorrect use of `await`
34 Ok(())
35}
36async fn foo5() -> Result<(), ()> {
37 let _ = bar().await(); //~ ERROR incorrect use of `await`
38 Ok(())
39}
40async fn foo6() -> Result<(), ()> {
41 let _ = bar().await()?; //~ ERROR incorrect use of `await`
42 Ok(())
43}
44async fn foo7() -> Result<(), ()> {
45 let _ = bar().await; // OK
46 Ok(())
47}
48async fn foo8() -> Result<(), ()> {
49 let _ = bar().await?; // OK
50 Ok(())
51}
52fn 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}
57fn 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}
62fn 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}
68fn 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}
73fn 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}
78fn 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}
83fn foo15() -> Result<(), ()> {
84 let _ = bar().await; //~ ERROR `await` is only allowed inside `async` functions and blocks
85 Ok(())
86}
87fn foo16() -> Result<(), ()> {
88 let _ = bar().await?; //~ ERROR `await` is only allowed inside `async` functions and blocks
89 Ok(())
90}
91fn 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}
98fn 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
106async fn foo26() -> Result<(), ()> {
107 let _ = await!(bar()); //~ ERROR incorrect use of `await`
108 Ok(())
109}
110async fn foo27() -> Result<(), ()> {
111 let _ = await!(bar())?; //~ ERROR incorrect use of `await`
112 Ok(())
113}
114fn 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}
122fn 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
131fn 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 `}`