Address review comments.

This commit is contained in:
Mazdak Farrokhzad 2019-07-31 21:25:11 +02:00
parent f3a3290ba3
commit 6551285cca
2 changed files with 4 additions and 8 deletions

View file

@ -143,6 +143,7 @@ macro_rules! maybe_whole_expr {
$p.token.span, ExprKind::Block(block, None), ThinVec::new() $p.token.span, ExprKind::Block(block, None), ThinVec::new()
)); ));
} }
// N.B: `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
_ => {}, _ => {},
}; };
} }
@ -2781,12 +2782,7 @@ impl<'a> Parser<'a> {
// can't continue an expression after an ident // can't continue an expression after an ident
token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw), token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw),
token::Literal(..) | token::Pound => true, token::Literal(..) | token::Pound => true,
token::Interpolated(ref nt) => match **nt { _ => t.is_whole_expr(),
token::NtIdent(..) | token::NtExpr(..) |
token::NtBlock(..) | token::NtPath(..) => true,
_ => false,
},
_ => false
}; };
let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr); let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr);
if cannot_continue_expr { if cannot_continue_expr {

View file

@ -481,7 +481,7 @@ impl Token {
/// (which happens while parsing the result of macro expansion)? /// (which happens while parsing the result of macro expansion)?
crate fn is_whole_expr(&self) -> bool { crate fn is_whole_expr(&self) -> bool {
if let Interpolated(ref nt) = self.kind { if let Interpolated(ref nt) = self.kind {
if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtBlock(_) = **nt { if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt {
return true; return true;
} }
} }