Allow attributes on match arms

RFC: 0008-match-arm-attributes
This commit is contained in:
Steven Fackler
2014-04-22 21:54:48 -07:00
parent 3d05e7f9cd
commit 1452c9c04a
8 changed files with 66 additions and 3 deletions

View File

@@ -2539,6 +2539,7 @@ impl<'a> Parser<'a> {
self.commit_expr_expecting(discriminant, token::LBRACE);
let mut arms: Vec<Arm> = Vec::new();
while self.token != token::RBRACE {
let attrs = self.parse_outer_attributes();
let pats = self.parse_pats();
let mut guard = None;
if self.eat_keyword(keywords::If) {
@@ -2557,7 +2558,12 @@ impl<'a> Parser<'a> {
self.eat(&token::COMMA);
}
arms.push(ast::Arm { pats: pats, guard: guard, body: expr });
arms.push(ast::Arm {
attrs: attrs,
pats: pats,
guard: guard,
body: expr
});
}
let hi = self.span.hi;
self.bump();