Bubble parse error when expecting )

This commit is contained in:
Esteban Küber 2023-11-06 23:19:14 +00:00
parent 075c599188
commit 1994abed74
7 changed files with 25 additions and 51 deletions

View File

@ -875,6 +875,9 @@ impl<'a> Parser<'a> {
if self.token == token::Colon {
// we will try to recover in `maybe_recover_struct_lit_bad_delims`
return Err(expect_err);
} else if let [token::CloseDelim(Delimiter::Parenthesis)] = kets
{
return Err(expect_err);
} else {
expect_err.emit();
break;

View File

@ -12,7 +12,7 @@ fn main() {
//~^ ERROR unnecessary parentheses around `if` condition
// reported by parser
for _x in 1..10 {}
for(_x in 1..10){}
//~^ ERROR expected one of
//~| ERROR unexpected parentheses surrounding
}

View File

@ -4,18 +4,6 @@ error: expected one of `)`, `,`, `@`, or `|`, found keyword `in`
LL | for(_x in 1..10){}
| ^^ expected one of `)`, `,`, `@`, or `|`
error: unexpected parentheses surrounding `for` loop head
--> $DIR/issue-103435-extra-parentheses.rs:15:8
|
LL | for(_x in 1..10){}
| ^ ^
|
help: remove parentheses in `for` loop
|
LL - for(_x in 1..10){}
LL + for _x in 1..10 {}
|
error: unnecessary parentheses around pattern
--> $DIR/issue-103435-extra-parentheses.rs:5:11
|
@ -57,5 +45,5 @@ LL - if(2 == 1){}
LL + if 2 == 1 {}
|
error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

View File

@ -8,15 +8,11 @@ error: expected one of `)`, `+`, or `,`, found `a`
--> $DIR/issue-68890.rs:1:15
|
LL | enum e{A((?'a a+?+l))}
| ^ expected one of `)`, `+`, or `,`
error: expected item, found `)`
--> $DIR/issue-68890.rs:1:21
| - ^ expected one of `)`, `+`, or `,`
| |
| while parsing this enum
|
LL | enum e{A((?'a a+?+l))}
| ^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

View File

@ -9,8 +9,20 @@ LL | abc: {},
error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `{`
--> $DIR/recover-enum2.rs:25:22
|
LL | enum Test4 {
| ----- while parsing this enum
LL | Nope(i32 {})
| ^ expected one of 7 possible tokens
|
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
error: aborting due to 2 previous errors
error: expected item, found `}`
--> $DIR/recover-enum2.rs:28:1
|
LL | }
| ^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
error: aborting due to 3 previous errors

View File

@ -4,24 +4,5 @@ error: expected one of `)`, `,`, `@`, or `|`, found keyword `in`
LL | for ( elem in vec ) {
| ^^ expected one of `)`, `,`, `@`, or `|`
error: unexpected parentheses surrounding `for` loop head
--> $DIR/recover-for-loop-parens-around-head.rs:10:9
|
LL | for ( elem in vec ) {
| ^ ^
|
help: remove parentheses in `for` loop
|
LL - for ( elem in vec ) {
LL + for elem in vec {
|
error: aborting due to previous error
error[E0308]: mismatched types
--> $DIR/recover-for-loop-parens-around-head.rs:13:38
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -4,11 +4,5 @@ error: expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found keyword `if`
LL | (0 if true) => {
| ^^ expected one of `)`, `,`, `...`, `..=`, `..`, or `|`
error: expected one of `.`, `=>`, `?`, or an operator, found `)`
--> $DIR/recover-parens-around-match-arm-head.rs:4:19
|
LL | (0 if true) => {
| ^ expected one of `.`, `=>`, `?`, or an operator
error: aborting due to 2 previous errors
error: aborting due to previous error