Skip to content

Commit 603ca3f

Browse files
committed
Add regression tests for await macro suggestions
1 parent 6eeff9a commit 603ca3f

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ edition: 2024
2+
3+
// Replacing `await!(...)` must preserve grouping and any following `?`.
4+
5+
use std::future::ready;
6+
7+
async fn check() -> Result<(), ()> {
8+
let future = ready(1);
9+
let _: i32 = await!(future);
10+
//~^ ERROR incorrect use of `await`
11+
let _: i32 = await!(ready(1));
12+
//~^ ERROR incorrect use of `await`
13+
let _: i32 = await!(ready(Ok::<i32, ()>(1)))?;
14+
//~^ ERROR incorrect use of `await`
15+
let _: i32 = await!(/* keep */ &mut ready(1) /* keep */);
16+
//~^ ERROR incorrect use of `await`
17+
Ok(())
18+
}
19+
20+
fn main() {
21+
let _ = check();
22+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
error: incorrect use of `await`
2+
--> $DIR/await-macro-rustfix.rs:9:18
3+
|
4+
LL | let _: i32 = await!(future);
5+
| ^^^^^^^^^^^^^^
6+
|
7+
help: `await` is a postfix operation
8+
|
9+
LL - let _: i32 = await!(future);
10+
LL + let _: i32 = future.await);
11+
|
12+
13+
error: incorrect use of `await`
14+
--> $DIR/await-macro-rustfix.rs:11:18
15+
|
16+
LL | let _: i32 = await!(ready(1));
17+
| ^^^^^^^^^^^^^^^^
18+
|
19+
help: `await` is a postfix operation
20+
|
21+
LL - let _: i32 = await!(ready(1));
22+
LL + let _: i32 = ready(1).await);
23+
|
24+
25+
error: incorrect use of `await`
26+
--> $DIR/await-macro-rustfix.rs:13:18
27+
|
28+
LL | let _: i32 = await!(ready(Ok::<i32, ()>(1)))?;
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
|
31+
help: `await` is a postfix operation
32+
|
33+
LL - let _: i32 = await!(ready(Ok::<i32, ()>(1)))?;
34+
LL + let _: i32 = ready(Ok::<i32, ()>(1)).await)?;
35+
|
36+
37+
error: incorrect use of `await`
38+
--> $DIR/await-macro-rustfix.rs:15:18
39+
|
40+
LL | let _: i32 = await!(/* keep */ &mut ready(1) /* keep */);
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
|
43+
help: `await` is a postfix operation
44+
|
45+
LL - let _: i32 = await!(/* keep */ &mut ready(1) /* keep */);
46+
LL + let _: i32 = &mut ready(1).await /* keep */);
47+
|
48+
49+
error: aborting due to 4 previous errors
50+

0 commit comments

Comments
 (0)