syntax: allow negative integer literal expression to be interpolated as pattern

This commit is contained in:
Alex Burka
2017-06-24 18:26:04 +00:00
parent 229d0d3266
commit 0dfd9c30f2
5 changed files with 103 additions and 8 deletions

View File

@@ -1659,8 +1659,10 @@ impl<'a> Parser<'a> {
Ok(codemap::Spanned { node: lit, span: lo.to(self.prev_span) })
}
/// matches '-' lit | lit
/// matches '-' lit | lit (cf. ast_validation::AstValidator::check_expr_within_pat)
pub fn parse_pat_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
maybe_whole_expr!(self);
let minus_lo = self.span;
let minus_present = self.eat(&token::BinOp(token::Minus));
let lo = self.span;