diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 93d7a597681..d3f5a37fd6e 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1017,7 +1017,7 @@ pub struct Local { /// ``` #[derive(Clone, Encodable, Decodable, Debug)] pub struct Arm { - pub attrs: Vec, + pub attrs: AttrVec, /// Match arm pattern, e.g. `10` in `match foo { 10 => {}, _ => {} }` pub pat: P, /// Match arm guard, e.g. `n > 10` in `match foo { n if n > 10 => {}, _ => {} }` @@ -2293,7 +2293,7 @@ pub struct EnumDef { #[derive(Clone, Encodable, Decodable, Debug)] pub struct Variant { /// Attributes of the variant. - pub attrs: Vec, + pub attrs: AttrVec, /// Id of the variant (not the constructor, see `VariantData::ctor_id()`). pub id: NodeId, /// Span @@ -2474,7 +2474,7 @@ pub fn is_pub(&self) -> bool { /// E.g., `bar: usize` as in `struct Foo { bar: usize }`. #[derive(Clone, Encodable, Decodable, Debug)] pub struct FieldDef { - pub attrs: Vec, + pub attrs: AttrVec, pub id: NodeId, pub span: Span, pub vis: Visibility, diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 0b6099fd330..296766f8019 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -420,7 +420,7 @@ pub fn noop_visit_use_tree(use_tree: &mut UseTree, vis: &mut T) { pub fn noop_flat_map_arm(mut arm: Arm, vis: &mut T) -> SmallVec<[Arm; 1]> { let Arm { attrs, pat, guard, body, span, id, is_placeholder: _ } = &mut arm; - visit_attrs(attrs, vis); + visit_thin_attrs(attrs, vis); vis.visit_id(id); vis.visit_pat(pat); visit_opt(guard, |guard| vis.visit_expr(guard)); @@ -504,7 +504,7 @@ pub fn noop_flat_map_variant( let Variant { ident, vis, attrs, id, data, disr_expr, span, is_placeholder: _ } = &mut variant; visitor.visit_ident(ident); visitor.visit_vis(vis); - visit_attrs(attrs, visitor); + visit_thin_attrs(attrs, visitor); visitor.visit_id(id); visitor.visit_variant_data(data); visit_opt(disr_expr, |disr_expr| visitor.visit_anon_const(disr_expr)); @@ -918,7 +918,7 @@ pub fn noop_flat_map_field_def( visitor.visit_vis(vis); visitor.visit_id(id); visitor.visit_ty(ty); - visit_attrs(attrs, visitor); + visit_thin_attrs(attrs, visitor); smallvec![fd] } diff --git a/compiler/rustc_ast_pretty/src/pprust/tests.rs b/compiler/rustc_ast_pretty/src/pprust/tests.rs index b1a73a0bf02..8abd85a5a52 100644 --- a/compiler/rustc_ast_pretty/src/pprust/tests.rs +++ b/compiler/rustc_ast_pretty/src/pprust/tests.rs @@ -49,7 +49,7 @@ fn test_variant_to_string() { kind: ast::VisibilityKind::Inherited, tokens: None, }, - attrs: Vec::new(), + attrs: ast::AttrVec::new(), id: ast::DUMMY_NODE_ID, data: ast::VariantData::Unit(ast::DUMMY_NODE_ID), disr_expr: None, diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index ef5b97a9469..824df2757ea 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -432,7 +432,7 @@ pub fn pat_some(&self, span: Span, pat: P) -> P { pub fn arm(&self, span: Span, pat: P, expr: P) -> ast::Arm { ast::Arm { - attrs: vec![], + attrs: AttrVec::new(), pat, guard: None, body: expr, diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index c8789abc142..88ebf4aca23 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2116,7 +2116,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 +2170,7 @@ pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> { Ok(( ast::Arm { - attrs, + attrs: attrs.into(), pat, guard, body: expr, diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 54e6ff6272c..2daa9e2485b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1143,7 +1143,7 @@ fn parse_enum_variant(&mut self) -> PResult<'a, Option> { 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> { 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, }) } diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs index 5597af9ee32..974c0c5990c 100644 --- a/src/tools/rustfmt/src/types.rs +++ b/src/tools/rustfmt/src/types.rs @@ -1,7 +1,7 @@ use std::iter::ExactSizeIterator; use std::ops::Deref; -use rustc_ast::ast::{self, FnRetTy, Mutability}; +use rustc_ast::ast::{self, AttrVec, FnRetTy, Mutability}; use rustc_span::{symbol::kw, symbol::Ident, BytePos, Pos, Span}; use crate::config::lists::*; @@ -776,7 +776,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option ); let data = ast::VariantData::Struct(fields.clone(), recovered); let variant = ast::Variant { - attrs: vec![], + attrs: AttrVec::new(), id: self.id, span: self.span, vis: DEFAULT_VISIBILITY, @@ -800,7 +800,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option ); let data = ast::VariantData::Struct(fields.clone(), recovered); let variant = ast::Variant { - attrs: vec![], + attrs: AttrVec::new(), id: self.id, span: self.span, vis: DEFAULT_VISIBILITY,