about summary refs log tree commit diff
path: root/src/librustc_parse/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-07 00:08:44 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-23 13:44:06 +0100
commit287ba5d0c8383c011b248db5b8a7a65b52fdd242 (patch)
tree7e1af09e9c000e546a89063fcc0ce3fcf92c71b2 /src/librustc_parse/parser
parent98701b2c613cbfe686f7fabd7f1106776b2e3aed (diff)
downloadrust-287ba5d0c8383c011b248db5b8a7a65b52fdd242.tar.gz
rust-287ba5d0c8383c011b248db5b8a7a65b52fdd242.zip
extract parse_fn_call_expr
Diffstat (limited to 'src/librustc_parse/parser')
-rw-r--r--src/librustc_parse/parser/expr.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index 09563e68096..f20e5d6aa92 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -756,15 +756,7 @@ impl<'a> Parser<'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 @@ impl<'a> Parser<'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(); // `[`