]> git.lizzy.rs Git - rust.git/commitdiff
parse_bottom_expr: use else if
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 3 Dec 2019 09:30:40 +0000 (10:30 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Fri, 20 Dec 2019 21:41:29 +0000 (22:41 +0100)
src/librustc_parse/parser/expr.rs

index 0792f1b3b7f646cd8925b7ca3f7a8ced94aef328..7af9b7267a87f92ef6947ce0f1e9f1b3202162b4 100644 (file)
@@ -1093,21 +1093,20 @@ macro_rules! parse_lit {
                     let (await_hi, e_kind) = self.parse_incorrect_await_syntax(lo, self.prev_span)?;
                     hi = await_hi;
                     ex = e_kind;
+                } else if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
+                    // Don't complain about bare semicolons after unclosed braces
+                    // recovery in order to keep the error count down. Fixing the
+                    // delimiters will possibly also fix the bare semicolon found in
+                    // expression context. For example, silence the following error:
+                    //
+                    //     error: expected expression, found `;`
+                    //      --> file.rs:2:13
+                    //       |
+                    //     2 |     foo(bar(;
+                    //       |             ^ expected expression
+                    self.bump();
+                    return Ok(self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()));
                 } else {
-                    if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
-                        // Don't complain about bare semicolons after unclosed braces
-                        // recovery in order to keep the error count down. Fixing the
-                        // delimiters will possibly also fix the bare semicolon found in
-                        // expression context. For example, silence the following error:
-                        //
-                        //     error: expected expression, found `;`
-                        //      --> file.rs:2:13
-                        //       |
-                        //     2 |     foo(bar(;
-                        //       |             ^ expected expression
-                        self.bump();
-                        return Ok(self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()));
-                    }
                     parse_lit!()
                 }
             }