Rollup merge of #63122 - Centril:fix-63115, r=petrochenkov

Account for `maybe_whole_expr` in range patterns

Fixes https://github.com/rust-lang/rust/issues/63115 (fallout from https://github.com/rust-lang/rust/pull/62550).

r? @petrochenkov
This commit is contained in:
Pietro Albini 2019-08-01 16:00:26 +02:00 committed by GitHub
commit 810ffe2ba0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 142 additions and 7 deletions

View 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`.
_ => {},
};
}
@ -2756,12 +2757,7 @@ impl<'a> Parser<'a> {
// 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 {
@ -3728,6 +3724,7 @@ impl<'a> Parser<'a> {
self.token.is_path_start() // e.g. `MY_CONST`;
|| self.token == token::Dot // e.g. `.5` for recovery;
|| self.token.can_begin_literal_or_bool() // e.g. `42`.
|| self.token.is_whole_expr()
}
// Helper function to decide whether to parse as ident binding