]> git.lizzy.rs Git - rust.git/commitdiff
extract parse_fn_call_expr
authorMazdak Farrokhzad <twingoow@gmail.com>
Fri, 6 Dec 2019 23:08:44 +0000 (00:08 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Mon, 23 Dec 2019 12:44:06 +0000 (13:44 +0100)
src/librustc_parse/parser/expr.rs

index 09563e680965514c520a736408f2c924a53e2730..f20e5d6aa92bb454091a8e678d1a2be5d9100870 100644 (file)
@@ -756,15 +756,7 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
                 break;
             }
             match self.token.kind {
-                // expr(...)
-                token::OpenDelim(token::Paren) => {
-                    let seq = self.parse_paren_expr_seq().map(|es| {
-                        let nd = self.mk_call(e, es);
-                        let hi = self.prev_span;
-                        self.mk_expr(lo.to(hi), nd, AttrVec::new())
-                    });
-                    e = self.recover_seq_parse_error(token::Paren, lo, seq);
-                }
+                token::OpenDelim(token::Paren) => e = Ok(self.parse_fn_call_expr(lo, e)),
                 token::OpenDelim(token::Bracket) => e = self.parse_index_expr(lo, e)?,
                 _ => return Ok(e),
             }
@@ -772,6 +764,14 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
         return Ok(e);
     }
 
+    /// Parse a function call expression, `expr(...)`.
+    fn parse_fn_call_expr(&mut self, lo: Span, fun: P<Expr>) -> P<Expr> {
+        let seq = self.parse_paren_expr_seq().map(|args| {
+            self.mk_expr(lo.to(self.prev_span), self.mk_call(fun, args), AttrVec::new())
+        });
+        self.recover_seq_parse_error(token::Paren, lo, seq)
+    }
+
     /// Parse an indexing expression `expr[...]`.
     fn parse_index_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
         self.bump(); // `[`