Skip to content

Commit 01c6689

Browse files
committed
Simplify span usage for incorrect await
1 parent ee02661 commit 01c6689

File tree

3 files changed

+23
-45
lines changed

3 files changed

+23
-45
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ impl<'a> Parser<'a> {
27382738
ThinVec::new(),
27392739
);
27402740
let mut err = self.struct_span_err(
2741-
await_sp,
2741+
sp,
27422742
"incorrect use of `await`",
27432743
);
27442744
err.span_suggestion(
@@ -2775,7 +2775,7 @@ impl<'a> Parser<'a> {
27752775
.unwrap_or_else(|_| pprust::expr_to_string(&expr));
27762776
let sp = lo.to(expr.span);
27772777
let mut err = self.struct_span_err(
2778-
await_sp,
2778+
sp,
27792779
"incorrect use of `await`",
27802780
);
27812781
err.span_suggestion(
@@ -3010,7 +3010,7 @@ impl<'a> Parser<'a> {
30103010
self.bump(); // (
30113011
let sp = lo.to(self.span);
30123012
self.bump(); // )
3013-
let mut err = self.struct_span_err(span, "incorrect use of `await`");
3013+
let mut err = self.struct_span_err(sp, "incorrect use of `await`");
30143014
err.span_suggestion(
30153015
sp,
30163016
"`await` is not a method call, remove the parentheses",

src/test/ui/await-keyword/incorrect-syntax-suggestions.stderr

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,113 +2,91 @@ error: incorrect use of `await`
22
--> $DIR/incorrect-syntax-suggestions.rs:10:13
33
|
44
LL | let _ = await bar();
5-
| ^^^^^------
6-
| |
7-
| help: `await` is not a statement: `bar().await`
5+
| ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
86

97
error: incorrect use of `await`
108
--> $DIR/incorrect-syntax-suggestions.rs:14:13
119
|
1210
LL | let _ = await? bar();
13-
| ^^^^^-------
14-
| |
15-
| help: `await` is not a statement: `bar().await?`
11+
| ^^^^^^^^^^^^ help: `await` is not a statement: `bar().await?`
1612

1713
error: incorrect use of `await`
1814
--> $DIR/incorrect-syntax-suggestions.rs:18:13
1915
|
2016
LL | let _ = await bar()?;
21-
| ^^^^^-------
22-
| |
23-
| help: `await` is not a statement: `bar()?.await`
17+
| ^^^^^^^^^^^^ help: `await` is not a statement: `bar()?.await`
2418

2519
error: incorrect use of `await`
2620
--> $DIR/incorrect-syntax-suggestions.rs:23:13
2721
|
2822
LL | let _ = await { bar() };
29-
| ^^^^^----------
30-
| |
31-
| help: `await` is not a statement: `{ bar() }.await`
23+
| ^^^^^^^^^^^^^^^ help: `await` is not a statement: `{ bar() }.await`
3224

3325
error: incorrect use of `await`
3426
--> $DIR/incorrect-syntax-suggestions.rs:27:13
3527
|
3628
LL | let _ = await(bar());
37-
| ^^^^^-------
38-
| |
39-
| help: `await` is not a statement: `(bar()).await`
29+
| ^^^^^^^^^^^^ help: `await` is not a statement: `(bar()).await`
4030

4131
error: incorrect use of `await`
4232
--> $DIR/incorrect-syntax-suggestions.rs:31:13
4333
|
4434
LL | let _ = await { bar() }?;
45-
| ^^^^^----------
46-
| |
47-
| help: `await` is not a statement: `{ bar() }.await`
35+
| ^^^^^^^^^^^^^^^ help: `await` is not a statement: `{ bar() }.await`
4836

4937
error: incorrect use of `await`
5038
--> $DIR/incorrect-syntax-suggestions.rs:35:14
5139
|
5240
LL | let _ = (await bar())?;
53-
| ^^^^^------
54-
| |
55-
| help: `await` is not a statement: `bar().await`
41+
| ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
5642

5743
error: incorrect use of `await`
58-
--> $DIR/incorrect-syntax-suggestions.rs:39:13
44+
--> $DIR/incorrect-syntax-suggestions.rs:39:24
5945
|
6046
LL | let _ = bar().await();
61-
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses
47+
| ^^ help: `await` is not a method call, remove the parentheses
6248

6349
error: incorrect use of `await`
64-
--> $DIR/incorrect-syntax-suggestions.rs:43:13
50+
--> $DIR/incorrect-syntax-suggestions.rs:43:24
6551
|
6652
LL | let _ = bar().await()?;
67-
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses
53+
| ^^ help: `await` is not a method call, remove the parentheses
6854

6955
error: incorrect use of `await`
7056
--> $DIR/incorrect-syntax-suggestions.rs:55:13
7157
|
7258
LL | let _ = await bar();
73-
| ^^^^^------
74-
| |
75-
| help: `await` is not a statement: `bar().await`
59+
| ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
7660

7761
error: incorrect use of `await`
7862
--> $DIR/incorrect-syntax-suggestions.rs:60:13
7963
|
8064
LL | let _ = await? bar();
81-
| ^^^^^-------
82-
| |
83-
| help: `await` is not a statement: `bar().await?`
65+
| ^^^^^^^^^^^^ help: `await` is not a statement: `bar().await?`
8466

8567
error: incorrect use of `await`
8668
--> $DIR/incorrect-syntax-suggestions.rs:65:13
8769
|
8870
LL | let _ = await bar()?;
89-
| ^^^^^-------
90-
| |
91-
| help: `await` is not a statement: `bar()?.await`
71+
| ^^^^^^^^^^^^ help: `await` is not a statement: `bar()?.await`
9272

9373
error: incorrect use of `await`
9474
--> $DIR/incorrect-syntax-suggestions.rs:70:14
9575
|
9676
LL | let _ = (await bar())?;
97-
| ^^^^^------
98-
| |
99-
| help: `await` is not a statement: `bar().await`
77+
| ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
10078

10179
error: incorrect use of `await`
102-
--> $DIR/incorrect-syntax-suggestions.rs:75:13
80+
--> $DIR/incorrect-syntax-suggestions.rs:75:24
10381
|
10482
LL | let _ = bar().await();
105-
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses
83+
| ^^ help: `await` is not a method call, remove the parentheses
10684

10785
error: incorrect use of `await`
108-
--> $DIR/incorrect-syntax-suggestions.rs:80:13
86+
--> $DIR/incorrect-syntax-suggestions.rs:80:24
10987
|
11088
LL | let _ = bar().await()?;
111-
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses
89+
| ^^ help: `await` is not a method call, remove the parentheses
11290

11391
error[E0728]: `await` is only allowed inside `async` functions and blocks
11492
--> $DIR/incorrect-syntax-suggestions.rs:55:13

src/test/ui/feature-gate/await-macro.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0658]: `await!(<expr>)` macro syntax is unstable, and will soon be remove
22
--> $DIR/await-macro.rs:9:5
33
|
44
LL | await!(bar());
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/50547
88
= help: add #![feature(await_macro)] to the crate attributes to enable

0 commit comments

Comments
 (0)