File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -731,7 +731,7 @@ impl<'a> Parser<'a> {
731
731
Applicability :: MaybeIncorrect ,
732
732
) ;
733
733
err. emit ( ) ;
734
- // self.expected_tokens.clear(); // reduce errors
734
+ self . expected_tokens . clear ( ) ; // reduce errors
735
735
Ok ( true )
736
736
}
737
737
_ => Err ( err) ,
@@ -2814,6 +2814,21 @@ impl<'a> Parser<'a> {
2814
2814
hi = pth. span ;
2815
2815
ex = ExprKind :: Path ( None , pth) ;
2816
2816
} else {
2817
+ if !self . unclosed_delims . is_empty ( ) && self . check ( & token:: Semi ) {
2818
+ // Don't complain about bare semicolons after unclosed braces
2819
+ // recovery in order to keep the error count down. Fixing the
2820
+ // delimiters will possibly also fix the bare semicolon found in
2821
+ // expression context. For example, silence the following error:
2822
+ // ```
2823
+ // error: expected expression, found `;`
2824
+ // --> file.rs:2:13
2825
+ // |
2826
+ // 2 | foo(bar(;
2827
+ // | ^ expected expression
2828
+ // ```
2829
+ self . bump ( ) ;
2830
+ return Ok ( self . mk_expr ( self . span , ExprKind :: Err , ThinVec :: new ( ) ) ) ;
2831
+ }
2817
2832
match self . parse_literal_maybe_minus ( ) {
2818
2833
Ok ( expr) => {
2819
2834
hi = expr. span ;
Original file line number Diff line number Diff line change 2
2
3
3
fn main( ) {
4
4
foo( bar( ;
5
- //~^ ERROR: expected expression, found `;`
5
+ //~^ ERROR cannot find function `bar` in this scope
6
6
}
7
7
//~^ ERROR: incorrect close delimiter: `}`
8
+
9
+ fn foo ( _: usize ) { }
Original file line number Diff line number Diff line change 1
- error: expected expression, found `;`
2
- --> $DIR/token-error-correct.rs:4:13
3
- |
4
- LL | foo(bar(;
5
- | ^ expected expression
6
-
7
1
error: incorrect close delimiter: `}`
8
2
--> $DIR/token-error-correct.rs:6:1
9
3
|
10
4
LL | fn main() {
11
5
| - close delimiter possibly meant for this
12
6
LL | foo(bar(;
13
7
| - un-closed delimiter
14
- LL | //~^ ERROR: expected expression, found `;`
8
+ LL | //~^ ERROR cannot find function `bar` in this scope
15
9
LL | }
16
10
| ^ incorrect close delimiter
17
11
12
+ error[E0425]: cannot find function `bar` in this scope
13
+ --> $DIR/token-error-correct.rs:4:9
14
+ |
15
+ LL | foo(bar(;
16
+ | ^^^ not found in this scope
17
+
18
18
error: aborting due to 2 previous errors
19
19
20
+ For more information about this error, try `rustc --explain E0425`.
You can’t perform that action at this time.
0 commit comments