]> git.lizzy.rs Git - rust.git/commitdiff
Address review comments.
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 31 Jul 2019 19:25:11 +0000 (21:25 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Wed, 31 Jul 2019 19:25:11 +0000 (21:25 +0200)
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs

index 2fa6d20430bf1aa9033dc49c54da0db4d1cdb7fc..ae4925ec340832ba9672c6c4559dd6c1de996051 100644 (file)
@@ -143,6 +143,7 @@ macro_rules! maybe_whole_expr {
                         $p.token.span, ExprKind::Block(block, None), ThinVec::new()
                     ));
                 }
+                // N.B: `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
                 _ => {},
             };
         }
@@ -2781,12 +2782,7 @@ fn parse_prefix_expr(&mut self,
                     // can't continue an expression after an ident
                     token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw),
                     token::Literal(..) | token::Pound => true,
-                    token::Interpolated(ref nt) => match **nt {
-                        token::NtIdent(..) | token::NtExpr(..) |
-                        token::NtBlock(..) | token::NtPath(..) => true,
-                        _ => false,
-                    },
-                    _ => false
+                    _ => t.is_whole_expr(),
                 };
                 let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr);
                 if cannot_continue_expr {
index d6d13c19f7183c4a94274764068aeb7f9a47eda7..73adb5c947c0b64ab777780c80a0e75bb1877df8 100644 (file)
@@ -478,10 +478,10 @@ fn is_path(&self) -> bool {
 
     /// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
     /// That is, is this a pre-parsed expression dropped into the token stream
-    /// (which happens while parsing the result ofmacro expansion)?
+    /// (which happens while parsing the result of macro expansion)?
     crate fn is_whole_expr(&self) -> bool {
         if let Interpolated(ref nt) = self.kind {
-            if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtBlock(_) = **nt {
+            if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt {
                 return true;
             }
         }