mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Bubble parse error when expecting )
This commit is contained in:
parent
075c599188
commit
1994abed74
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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`.
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user