1
Fork 0

Give match arms an HirId and a Span

This commit is contained in:
Matthew Jasper 2019-03-30 22:54:29 +00:00
parent 615c23f6ec
commit 4bfb0453f5
12 changed files with 53 additions and 10 deletions

View file

@ -3946,6 +3946,7 @@ impl<'a> Parser<'a> {
crate fn parse_arm(&mut self) -> PResult<'a, Arm> {
let attrs = self.parse_outer_attributes()?;
let lo = self.span;
let pats = self.parse_pats()?;
let guard = if self.eat_keyword(keywords::If) {
Some(Guard::If(self.parse_expr()?))
@ -3965,6 +3966,8 @@ impl<'a> Parser<'a> {
let require_comma = classify::expr_requires_semi_to_be_stmt(&expr)
&& self.token != token::CloseDelim(token::Brace);
let hi = self.span;
if require_comma {
let cm = self.sess.source_map();
self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)])
@ -4008,6 +4011,7 @@ impl<'a> Parser<'a> {
pats,
guard,
body: expr,
span: lo.to(hi),
})
}