]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_parse/src/parser/item.rs
Use `AttrVec` for `Arm`, `FieldDef`, and `Variant`
[rust.git] / compiler / rustc_parse / src / parser / item.rs
index c64fab0507c942636824149d7d5a6ea6e4c5e5c8..2daa9e2485b1b7a02de77e9bb064ccdc8d068759 100644 (file)
@@ -1143,7 +1143,7 @@ fn parse_enum_variant(&mut self) -> PResult<'a, Option<Variant>> {
                     ident,
                     vis,
                     id: DUMMY_NODE_ID,
-                    attrs: variant_attrs,
+                    attrs: variant_attrs.into(),
                     data: struct_def,
                     disr_expr,
                     span: vlo.to(this.prev_token.span),
@@ -1286,7 +1286,7 @@ fn parse_tuple_struct_body(&mut self) -> PResult<'a, Vec<FieldDef>> {
                         ident: None,
                         id: DUMMY_NODE_ID,
                         ty,
-                        attrs,
+                        attrs: attrs.into(),
                         is_placeholder: false,
                     },
                     TrailingToken::MaybeComma,
@@ -1460,7 +1460,7 @@ fn parse_name_and_ty(
             vis,
             id: DUMMY_NODE_ID,
             ty,
-            attrs,
+            attrs: attrs.into(),
             is_placeholder: false,
         })
     }
@@ -1474,7 +1474,10 @@ fn parse_field_ident(&mut self, adt_ty: &str, lo: Span) -> PResult<'a, Ident> {
                 self.sess.gated_spans.gate(sym::unnamed_fields, lo);
             } else {
                 let err = if self.check_fn_front_matter(false) {
-                    let _ = self.parse_fn(&mut Vec::new(), |_| true, lo);
+                    // We use `parse_fn` to get a span for the function
+                    if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
+                        db.delay_as_bug();
+                    }
                     let mut err = self.struct_span_err(
                         lo.to(self.prev_token.span),
                         &format!("functions are not allowed in {} definitions", adt_ty),