Tweak invalid fn header and body parsing
* Recover empty `fn` bodies when encountering `}` * Recover trailing `>` in return types * Recover from non-type in array type `[<BAD TOKEN>; LEN]`
This commit is contained in:
parent
040f568815
commit
ff61949860
7 changed files with 53 additions and 27 deletions
|
|
@ -1,4 +1,3 @@
|
|||
fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0`
|
||||
//~| ERROR expected one of `)`, `,`, `->`, `;`, `where`, or `{`, found `]`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,5 @@ error: expected type, found `0`
|
|||
LL | fn foo(a: [0; 1]) {}
|
||||
| ^ expected type
|
||||
|
||||
error: expected one of `)`, `,`, `->`, `;`, `where`, or `{`, found `]`
|
||||
--> $DIR/issue-39616.rs:1:16
|
||||
|
|
||||
LL | fn foo(a: [0; 1]) {}
|
||||
| ^ expected one of `)`, `,`, `->`, `;`, `where`, or `{`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// Verify that '>' is not both expected and found at the same time, as it used
|
||||
// to happen in #24780. For example, following should be an error:
|
||||
// expected one of ..., `>`, ... found `>`
|
||||
// expected one of ..., `>`, ... found `>`. No longer exactly this, but keeping for posterity.
|
||||
|
||||
fn foo() -> Vec<usize>> {
|
||||
//~^ ERROR expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
|
||||
fn foo() -> Vec<usize>> { //~ ERROR unmatched angle bracket
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
|
||||
error: unmatched angle bracket
|
||||
--> $DIR/issue-24780.rs:5:23
|
||||
|
|
||||
LL | fn foo() -> Vec<usize>> {
|
||||
| ^ expected one of `!`, `+`, `::`, `;`, `where`, or `{`
|
||||
| ^^ help: remove extra angle bracket
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ error: expected one of `->`, `;`, `where`, or `{`, found `}`
|
|||
--> $DIR/issue-6610.rs:1:20
|
||||
|
|
||||
LL | trait Foo { fn a() }
|
||||
| - ^
|
||||
| | |
|
||||
| | expected one of `->`, `;`, `where`, or `{`
|
||||
| | the item list ends here
|
||||
| while parsing this item list starting here
|
||||
| - ^ expected one of `->`, `;`, `where`, or `{`
|
||||
| |
|
||||
| while parsing this `fn`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue