]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_parse/src/parser/expr.rs
Recover from a misplaced inner doc comment
[rust.git] / compiler / rustc_parse / src / parser / expr.rs
index c8789abc142d6cf1179a8f0bf712398656e58620..9dff40ff1ed6eae2f310b21499ad2a17b3781e3f 100644 (file)
@@ -1945,7 +1945,7 @@ fn eat_label(&mut self) -> Option<Label> {
     }
 
     /// Parses a `match ... { ... }` expression (`match` token already eaten).
-    fn parse_match_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
+    fn parse_match_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let match_span = self.prev_token.span;
         let lo = self.prev_token.span;
         let scrutinee = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
@@ -1960,6 +1960,7 @@ fn parse_match_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
             }
             return Err(e);
         }
+        attrs.extend(self.parse_inner_attributes()?);
 
         let mut arms: Vec<Arm> = Vec::new();
         while self.token != token::CloseDelim(token::Brace) {
@@ -2116,7 +2117,7 @@ pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
                     let span = body.span;
                     return Ok((
                         ast::Arm {
-                            attrs,
+                            attrs: attrs.into(),
                             pat,
                             guard,
                             body,
@@ -2170,7 +2171,7 @@ pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
 
             Ok((
                 ast::Arm {
-                    attrs,
+                    attrs: attrs.into(),
                     pat,
                     guard,
                     body: expr,