Do not add ; to expected tokens list when it's wrong

There's a few spots where semicolons are checked for to do error recovery,
and should not be suggested (or checked for other stuff).

Fixes #87647
This commit is contained in:
Michael Howell 2021-12-04 11:05:30 -07:00
parent 532d2b14c0
commit 74437e477e
16 changed files with 90 additions and 51 deletions

View file

@ -3,6 +3,6 @@
fn foo() => impl Fn() => bool {
//~^ ERROR return types are denoted using `->`
//~| ERROR expected one of `+`, `->`, `::`, `;`, `where`, or `{`, found `=>`
//~| ERROR expected one of `+`, `->`, `::`, `where`, or `{`, found `=>`
unimplemented!()
}

View file

@ -4,11 +4,11 @@ error: return types are denoted using `->`
LL | fn foo() => impl Fn() => bool {
| ^^ help: use `->` instead
error: expected one of `+`, `->`, `::`, `;`, `where`, or `{`, found `=>`
error: expected one of `+`, `->`, `::`, `where`, or `{`, found `=>`
--> $DIR/fn-recover-return-sign2.rs:4:23
|
LL | fn foo() => impl Fn() => bool {
| ^^ expected one of `+`, `->`, `::`, `;`, `where`, or `{`
| ^^ expected one of `+`, `->`, `::`, `where`, or `{`
error: aborting due to 2 previous errors

View file

@ -2,7 +2,7 @@
// to happen in #24780. For example, following should be an error:
// expected one of ..., `>`, ... found `>`.
fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>`
Vec::new()
}

View file

@ -1,8 +1,8 @@
error: expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
error: expected one of `!`, `+`, `::`, `where`, or `{`, found `>`
--> $DIR/issue-24780.rs:5:23
|
LL | fn foo() -> Vec<usize>> {
| ^ expected one of `!`, `+`, `::`, `;`, `where`, or `{`
| ^ expected one of `!`, `+`, `::`, `where`, or `{`
error: aborting due to previous error

View file

@ -2,7 +2,7 @@ impl A {
//~^ ERROR cannot find type `A` in this scope
fn b(self>
//~^ ERROR expected one of `)`, `,`, or `:`, found `>`
//~| ERROR expected one of `->`, `;`, `where`, or `{`, found `>`
//~| ERROR expected one of `->`, `where`, or `{`, found `>`
}
fn main() {}

View file

@ -6,14 +6,14 @@ LL | fn b(self>
| |
| unclosed delimiter
error: expected one of `->`, `;`, `where`, or `{`, found `>`
error: expected one of `->`, `where`, or `{`, found `>`
--> $DIR/issue-58856-1.rs:3:14
|
LL | impl A {
| - while parsing this item list starting here
LL |
LL | fn b(self>
| ^ expected one of `->`, `;`, `where`, or `{`
| ^ expected one of `->`, `where`, or `{`
...
LL | }
| - the item list ends here

View file

@ -13,11 +13,11 @@ LL | fn f(t:for<>t?)
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
| help: missing `,`
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
error: expected one of `->`, `where`, or `{`, found `<eof>`
--> $DIR/issue-84148-1.rs:1:15
|
LL | fn f(t:for<>t?)
| ^ expected one of `->`, `;`, `where`, or `{`
| ^ expected one of `->`, `where`, or `{`
error: aborting due to 3 previous errors

View file

@ -21,11 +21,11 @@ LL | fn f(t:for<>t?
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
| help: missing `,`
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
error: expected one of `->`, `where`, or `{`, found `<eof>`
--> $DIR/issue-84148-2.rs:4:16
|
LL | fn f(t:for<>t?
| ^ expected one of `->`, `;`, `where`, or `{`
| ^ expected one of `->`, `where`, or `{`
error: aborting due to 4 previous errors

View file

@ -2,8 +2,8 @@ struct Foo {}
impl Foo {
pub fn bar()
//~^ ERROR: expected `;`, found `}`
//~| ERROR: associated function in `impl` without body
//~^ ERROR: associated function in `impl` without body
}
//~^ERROR expected one of `->`, `where`, or `{`, found `}`
fn main() {}

View file

@ -1,11 +1,13 @@
error: expected `;`, found `}`
--> $DIR/issue-87635.rs:4:17
error: expected one of `->`, `where`, or `{`, found `}`
--> $DIR/issue-87635.rs:6:1
|
LL | pub fn bar()
| ^ help: add `;` here
...
| --- - expected one of `->`, `where`, or `{`
| |
| while parsing this `fn`
LL |
LL | }
| - unexpected token
| ^ unexpected token
error: associated function in `impl` without body
--> $DIR/issue-87635.rs:4:5

View file

@ -22,11 +22,11 @@ error: expected one of `:` or `|`, found `)`
LL | fn main((ؼ
| ^ expected one of `:` or `|`
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
error: expected one of `->`, `where`, or `{`, found `<eof>`
--> $DIR/missing_right_paren.rs:3:11
|
LL | fn main((ؼ
| ^ expected one of `->`, `;`, `where`, or `{`
| ^ expected one of `->`, `where`, or `{`
error: aborting due to 4 previous errors