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 02:01:58 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-23 13:47:44 +0100
commit7ae12c9385230d6589fd0dae267f694338af8b45 (patch)
treedb7ec8072b0b2ffd184bbd7ef6b26480479f0451 /src/librustc_parse/parser
parentbc95228f1b01619e4faecf4694c1cd1f0938815d (diff)
downloadrust-7ae12c9385230d6589fd0dae267f694338af8b45.tar.gz
rust-7ae12c9385230d6589fd0dae267f694338af8b45.zip
extract parse_dot_base_expr
Diffstat (limited to 'src/librustc_parse/parser')
-rw-r--r--src/librustc_parse/parser/expr.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index f58b885522f..c18cf3565da 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -692,30 +692,27 @@ impl<'a> Parser<'a> {
         }
     }
 
-    fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
-        let mut e = e0;
+    fn parse_dot_or_call_expr_with_(&mut self, mut e: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
         loop {
-            // expr?
-            while self.eat(&token::Question) {
-                let hi = self.prev_span;
-                e = self.mk_expr(lo.to(hi), ExprKind::Try(e), AttrVec::new());
+            if self.eat(&token::Question) {
+                // `expr?`
+                e = self.mk_expr(lo.to(self.prev_span), ExprKind::Try(e), AttrVec::new());
+                continue;
             }
-
-            // expr.f
             if self.eat(&token::Dot) {
+                // expr.f
                 e = self.parse_dot_suffix_expr(lo, e)?;
                 continue;
             }
             if self.expr_is_complete(&e) {
-                break;
+                return Ok(e);
             }
-            match self.token.kind {
-                token::OpenDelim(token::Paren) => e = self.parse_fn_call_expr(lo, e),
-                token::OpenDelim(token::Bracket) => e = self.parse_index_expr(lo, e)?,
+            e = match self.token.kind {
+                token::OpenDelim(token::Paren) => self.parse_fn_call_expr(lo, e),
+                token::OpenDelim(token::Bracket) => self.parse_index_expr(lo, e)?,
                 _ => return Ok(e),
             }
         }
-        return Ok(e);
     }
 
     fn parse_dot_suffix_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {