1
Fork 0

Simplify span usage for incorrect await

This commit is contained in:
Esteban Küber 2019-05-15 20:06:15 -07:00
parent ee02661474
commit 01c6689604
3 changed files with 23 additions and 45 deletions

View file

@ -2738,7 +2738,7 @@ impl<'a> Parser<'a> {
ThinVec::new(), ThinVec::new(),
); );
let mut err = self.struct_span_err( let mut err = self.struct_span_err(
await_sp, sp,
"incorrect use of `await`", "incorrect use of `await`",
); );
err.span_suggestion( err.span_suggestion(
@ -2775,7 +2775,7 @@ impl<'a> Parser<'a> {
.unwrap_or_else(|_| pprust::expr_to_string(&expr)); .unwrap_or_else(|_| pprust::expr_to_string(&expr));
let sp = lo.to(expr.span); let sp = lo.to(expr.span);
let mut err = self.struct_span_err( let mut err = self.struct_span_err(
await_sp, sp,
"incorrect use of `await`", "incorrect use of `await`",
); );
err.span_suggestion( err.span_suggestion(
@ -3010,7 +3010,7 @@ impl<'a> Parser<'a> {
self.bump(); // ( self.bump(); // (
let sp = lo.to(self.span); let sp = lo.to(self.span);
self.bump(); // ) self.bump(); // )
let mut err = self.struct_span_err(span, "incorrect use of `await`"); let mut err = self.struct_span_err(sp, "incorrect use of `await`");
err.span_suggestion( err.span_suggestion(
sp, sp,
"`await` is not a method call, remove the parentheses", "`await` is not a method call, remove the parentheses",

View file

@ -2,113 +2,91 @@ error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:10:13 --> $DIR/incorrect-syntax-suggestions.rs:10:13
| |
LL | let _ = await bar(); LL | let _ = await bar();
| ^^^^^------ | ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
| |
| help: `await` is not a statement: `bar().await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:14:13 --> $DIR/incorrect-syntax-suggestions.rs:14:13
| |
LL | let _ = await? bar(); LL | let _ = await? bar();
| ^^^^^------- | ^^^^^^^^^^^^ help: `await` is not a statement: `bar().await?`
| |
| help: `await` is not a statement: `bar().await?`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:18:13 --> $DIR/incorrect-syntax-suggestions.rs:18:13
| |
LL | let _ = await bar()?; LL | let _ = await bar()?;
| ^^^^^------- | ^^^^^^^^^^^^ help: `await` is not a statement: `bar()?.await`
| |
| help: `await` is not a statement: `bar()?.await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:23:13 --> $DIR/incorrect-syntax-suggestions.rs:23:13
| |
LL | let _ = await { bar() }; LL | let _ = await { bar() };
| ^^^^^---------- | ^^^^^^^^^^^^^^^ help: `await` is not a statement: `{ bar() }.await`
| |
| help: `await` is not a statement: `{ bar() }.await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:27:13 --> $DIR/incorrect-syntax-suggestions.rs:27:13
| |
LL | let _ = await(bar()); LL | let _ = await(bar());
| ^^^^^------- | ^^^^^^^^^^^^ help: `await` is not a statement: `(bar()).await`
| |
| help: `await` is not a statement: `(bar()).await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:31:13 --> $DIR/incorrect-syntax-suggestions.rs:31:13
| |
LL | let _ = await { bar() }?; LL | let _ = await { bar() }?;
| ^^^^^---------- | ^^^^^^^^^^^^^^^ help: `await` is not a statement: `{ bar() }.await`
| |
| help: `await` is not a statement: `{ bar() }.await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:35:14 --> $DIR/incorrect-syntax-suggestions.rs:35:14
| |
LL | let _ = (await bar())?; LL | let _ = (await bar())?;
| ^^^^^------ | ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
| |
| help: `await` is not a statement: `bar().await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:39:13 --> $DIR/incorrect-syntax-suggestions.rs:39:24
| |
LL | let _ = bar().await(); LL | let _ = bar().await();
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses | ^^ help: `await` is not a method call, remove the parentheses
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:43:13 --> $DIR/incorrect-syntax-suggestions.rs:43:24
| |
LL | let _ = bar().await()?; LL | let _ = bar().await()?;
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses | ^^ help: `await` is not a method call, remove the parentheses
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:55:13 --> $DIR/incorrect-syntax-suggestions.rs:55:13
| |
LL | let _ = await bar(); LL | let _ = await bar();
| ^^^^^------ | ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
| |
| help: `await` is not a statement: `bar().await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:60:13 --> $DIR/incorrect-syntax-suggestions.rs:60:13
| |
LL | let _ = await? bar(); LL | let _ = await? bar();
| ^^^^^------- | ^^^^^^^^^^^^ help: `await` is not a statement: `bar().await?`
| |
| help: `await` is not a statement: `bar().await?`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:65:13 --> $DIR/incorrect-syntax-suggestions.rs:65:13
| |
LL | let _ = await bar()?; LL | let _ = await bar()?;
| ^^^^^------- | ^^^^^^^^^^^^ help: `await` is not a statement: `bar()?.await`
| |
| help: `await` is not a statement: `bar()?.await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:70:14 --> $DIR/incorrect-syntax-suggestions.rs:70:14
| |
LL | let _ = (await bar())?; LL | let _ = (await bar())?;
| ^^^^^------ | ^^^^^^^^^^^ help: `await` is not a statement: `bar().await`
| |
| help: `await` is not a statement: `bar().await`
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:75:13 --> $DIR/incorrect-syntax-suggestions.rs:75:24
| |
LL | let _ = bar().await(); LL | let _ = bar().await();
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses | ^^ help: `await` is not a method call, remove the parentheses
error: incorrect use of `await` error: incorrect use of `await`
--> $DIR/incorrect-syntax-suggestions.rs:80:13 --> $DIR/incorrect-syntax-suggestions.rs:80:24
| |
LL | let _ = bar().await()?; LL | let _ = bar().await()?;
| ^^^^^^^^^^^-- help: `await` is not a method call, remove the parentheses | ^^ help: `await` is not a method call, remove the parentheses
error[E0728]: `await` is only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/incorrect-syntax-suggestions.rs:55:13 --> $DIR/incorrect-syntax-suggestions.rs:55:13

View file

@ -2,7 +2,7 @@ error[E0658]: `await!(<expr>)` macro syntax is unstable, and will soon be remove
--> $DIR/await-macro.rs:9:5 --> $DIR/await-macro.rs:9:5
| |
LL | await!(bar()); LL | await!(bar());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^
| |
= note: for more information, see https://github.com/rust-lang/rust/issues/50547 = note: for more information, see https://github.com/rust-lang/rust/issues/50547
= help: add #![feature(await_macro)] to the crate attributes to enable = help: add #![feature(await_macro)] to the crate attributes to enable