From: Esteban Küber Date: Thu, 16 May 2019 03:06:15 +0000 (-0700) Subject: Simplify span usage for incorrect await X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=01c6689604d671c5fa51671940f69833222194ef;p=rust.git Simplify span usage for incorrect await --- diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 83bfd93d066..45081aadfd9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2738,7 +2738,7 @@ fn parse_async_macro_or_stmt( ThinVec::new(), ); let mut err = self.struct_span_err( - await_sp, + sp, "incorrect use of `await`", ); err.span_suggestion( @@ -2775,7 +2775,7 @@ fn parse_async_macro_or_stmt( .unwrap_or_else(|_| pprust::expr_to_string(&expr)); let sp = lo.to(expr.span); let mut err = self.struct_span_err( - await_sp, + sp, "incorrect use of `await`", ); err.span_suggestion( @@ -3010,7 +3010,7 @@ fn parse_dot_suffix(&mut self, self_arg: P, lo: Span) -> PResult<'a, P $DIR/incorrect-syntax-suggestions.rs:10:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:14:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:18:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:23:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:27:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:31:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:35:14 | 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` - --> $DIR/incorrect-syntax-suggestions.rs:39:13 + --> $DIR/incorrect-syntax-suggestions.rs:39:24 | 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` - --> $DIR/incorrect-syntax-suggestions.rs:43:13 + --> $DIR/incorrect-syntax-suggestions.rs:43:24 | 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` --> $DIR/incorrect-syntax-suggestions.rs:55:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:60:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:65:13 | 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` --> $DIR/incorrect-syntax-suggestions.rs:70:14 | 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` - --> $DIR/incorrect-syntax-suggestions.rs:75:13 + --> $DIR/incorrect-syntax-suggestions.rs:75:24 | 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` - --> $DIR/incorrect-syntax-suggestions.rs:80:13 + --> $DIR/incorrect-syntax-suggestions.rs:80:24 | 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 --> $DIR/incorrect-syntax-suggestions.rs:55:13 diff --git a/src/test/ui/feature-gate/await-macro.stderr b/src/test/ui/feature-gate/await-macro.stderr index 699a7a8886e..57aab6800f7 100644 --- a/src/test/ui/feature-gate/await-macro.stderr +++ b/src/test/ui/feature-gate/await-macro.stderr @@ -2,7 +2,7 @@ error[E0658]: `await!()` macro syntax is unstable, and will soon be remove --> $DIR/await-macro.rs:9:5 | LL | await!(bar()); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/50547 = help: add #![feature(await_macro)] to the crate attributes to enable