Auto merge of #55455 - estebank:expected-descr, r=michaelwoerister
Use token description in "expected/found" parse messages Fix #54309.
This commit is contained in:
commit
794fc062be
21 changed files with 66 additions and 44 deletions
|
|
@ -28,7 +28,7 @@ error: expected `{`, found `;`
|
|||
LL | if not // lack of braces is [sic]
|
||||
| -- this `if` statement has a condition, but no block
|
||||
LL | println!("Then when?");
|
||||
| ^
|
||||
| ^ expected `{`
|
||||
|
||||
error: unexpected `2` after identifier
|
||||
--> $DIR/issue-46836-identifier-not-instead-of-negation.rs:36:24
|
||||
|
|
|
|||
|
|
@ -16,3 +16,4 @@ fn main() {
|
|||
}
|
||||
}
|
||||
//~^ ERROR expected `{`, found `}`
|
||||
//~| NOTE expected `{`
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | if 5 == {
|
|||
| -- this `if` statement has a condition, but no block
|
||||
...
|
||||
LL | }
|
||||
| ^
|
||||
| ^ expected `{`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: expected `{`, found `in`
|
||||
error: expected `{`, found keyword `in`
|
||||
--> $DIR/issue-51602.rs:12:10
|
||||
|
|
||||
LL | if i in 1..10 {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ LL | if $tgt.has_$field() {}
|
|||
| this `if` statement has a condition, but no block
|
||||
...
|
||||
LL | get_opt!(bar, foo);
|
||||
| ^^^
|
||||
| ^^^ expected `{`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ error: expected `{`, found `'b`
|
|||
LL | if true 'b: {} //~ ERROR expected `{`, found `'b`
|
||||
| -- ^^----
|
||||
| | |
|
||||
| | expected `{`
|
||||
| | help: try placing this code inside a block: `{ 'b: { } }`
|
||||
| this `if` statement has a condition, but no block
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ error: expected `{`, found `'b`
|
|||
LL | if true {} else 'b: {} //~ ERROR expected `{`, found `'b`
|
||||
| ^^----
|
||||
| |
|
||||
| expected `{`
|
||||
| help: try placing this code inside a block: `{ 'b: { } }`
|
||||
|
||||
error: expected one of `.`, `?`, `{`, or an operator, found `'b`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: expected `{`, found `=>`
|
|||
--> $DIR/missing-block-hint.rs:13:18
|
||||
|
|
||||
LL | if (foo) => {} //~ ERROR expected `{`, found `=>`
|
||||
| -- ^^
|
||||
| -- ^^ expected `{`
|
||||
| |
|
||||
| this `if` statement has a condition, but no block
|
||||
|
||||
|
|
@ -14,6 +14,7 @@ LL | if (foo)
|
|||
LL | bar; //~ ERROR expected `{`, found `bar`
|
||||
| ^^^-
|
||||
| |
|
||||
| expected `{`
|
||||
| help: try placing this code inside a block: `{ bar; }`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: expected `;`, found `let`
|
||||
warning: expected `;`, found keyword `let`
|
||||
--> $DIR/missing-semicolon-warning.rs:16:12
|
||||
|
|
||||
LL | $( let x = $e1 )*; //~ WARN expected `;`
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
fn /// document
|
||||
foo() {}
|
||||
//~^^ ERROR expected identifier, found `/// document`
|
||||
//~^^ ERROR expected identifier, found doc comment `/// document`
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: expected identifier, found `/// document`
|
||||
error: expected identifier, found doc comment `/// document`
|
||||
--> $DIR/doc-before-identifier.rs:13:4
|
||||
|
|
||||
LL | fn /// document
|
||||
| ^^^^^^^^^^^^ expected identifier
|
||||
| ^^^^^^^^^^^^ expected identifier, found doc comment
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
4
src/test/ui/parser/doc-comment-in-if-statement.rs
Normal file
4
src/test/ui/parser/doc-comment-in-if-statement.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
if true /*!*/ {}
|
||||
//~^ ERROR expected `{`, found doc comment `/*!*/`
|
||||
}
|
||||
10
src/test/ui/parser/doc-comment-in-if-statement.stderr
Normal file
10
src/test/ui/parser/doc-comment-in-if-statement.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: expected `{`, found doc comment `/*!*/`
|
||||
--> $DIR/doc-comment-in-if-statement.rs:2:13
|
||||
|
|
||||
LL | if true /*!*/ {}
|
||||
| -- ^^^^^ expected `{`
|
||||
| |
|
||||
| this `if` statement has a condition, but no block
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
error: expected `;`, found `as`
|
||||
error: expected `;`, found keyword `as`
|
||||
--> $DIR/import-from-rename.rs:15:16
|
||||
|
|
||||
LL | use foo::{bar} as baz;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: expected `;`, found `as`
|
||||
error: expected `;`, found keyword `as`
|
||||
--> $DIR/import-glob-rename.rs:15:12
|
||||
|
|
||||
LL | use foo::* as baz;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
// compile-flags: -Z parse-only -Z continue-parse-after-error
|
||||
|
||||
struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where`
|
||||
struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: expected item, found `where`
|
||||
error: expected item, found keyword `where`
|
||||
--> $DIR/issue-17904-2.rs:13:24
|
||||
|
|
||||
LL | struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where`
|
||||
LL | struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where`
|
||||
| ^^^^^ expected item
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
// Test syntax checks for `type` keyword.
|
||||
|
||||
struct S1 for type; //~ ERROR expected `where`, `{`, `(`, or `;` after struct name, found `for`
|
||||
struct S1 for type;
|
||||
//~^ ERROR expected `where`, `{`, `(`, or `;` after struct name, found keyword `for`
|
||||
|
||||
pub fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: expected `where`, `{`, `(`, or `;` after struct name, found `for`
|
||||
error: expected `where`, `{`, `(`, or `;` after struct name, found keyword `for`
|
||||
--> $DIR/unsized.rs:15:11
|
||||
|
|
||||
LL | struct S1 for type; //~ ERROR expected `where`, `{`, `(`, or `;` after struct name, found `for`
|
||||
LL | struct S1 for type;
|
||||
| ^^^ expected `where`, `{`, `(`, or `;` after struct name
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
// Test diagnostics for the removed struct inheritance feature.
|
||||
|
||||
virtual struct SuperStruct { //~ ERROR expected item, found `virtual`
|
||||
virtual struct SuperStruct {
|
||||
//~^ ERROR expected item, found reserved keyword `virtual`
|
||||
f1: isize,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: expected item, found `virtual`
|
||||
error: expected item, found reserved keyword `virtual`
|
||||
--> $DIR/virtual-structs.rs:15:1
|
||||
|
|
||||
LL | virtual struct SuperStruct { //~ ERROR expected item, found `virtual`
|
||||
LL | virtual struct SuperStruct {
|
||||
| ^^^^^^^ expected item
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue