Skip to content

Use AttrVec for Arm, FieldDef, and Variant #86385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ pub struct Local {
/// ```
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct Arm {
pub attrs: Vec<Attribute>,
pub attrs: AttrVec,
/// Match arm pattern, e.g. `10` in `match foo { 10 => {}, _ => {} }`
pub pat: P<Pat>,
/// Match arm guard, e.g. `n > 10` in `match foo { n if n > 10 => {}, _ => {} }`
Expand Down Expand Up @@ -2293,7 +2293,7 @@ pub struct EnumDef {
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct Variant {
/// Attributes of the variant.
pub attrs: Vec<Attribute>,
pub attrs: AttrVec,
/// Id of the variant (not the constructor, see `VariantData::ctor_id()`).
pub id: NodeId,
/// Span
Expand Down Expand Up @@ -2474,7 +2474,7 @@ impl VisibilityKind {
/// E.g., `bar: usize` as in `struct Foo { bar: usize }`.
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct FieldDef {
pub attrs: Vec<Attribute>,
pub attrs: AttrVec,
pub id: NodeId,
pub span: Span,
pub vis: Visibility,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ pub fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {

pub fn noop_flat_map_arm<T: MutVisitor>(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));
Expand Down Expand Up @@ -504,7 +504,7 @@ pub fn noop_flat_map_variant<T: MutVisitor>(
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));
Expand Down Expand Up @@ -918,7 +918,7 @@ pub fn noop_flat_map_field_def<T: MutVisitor>(
visitor.visit_vis(vis);
visitor.visit_id(id);
visitor.visit_ty(ty);
visit_attrs(attrs, visitor);
visit_thin_attrs(attrs, visitor);
smallvec![fd]
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pprust/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl<'a> ExtCtxt<'a> {

pub fn arm(&self, span: Span, pat: P<ast::Pat>, expr: P<ast::Expr>) -> ast::Arm {
ast::Arm {
attrs: vec![],
attrs: AttrVec::new(),
pat,
guard: None,
body: expr,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ impl<'a> Parser<'a> {
let span = body.span;
return Ok((
ast::Arm {
attrs,
attrs: attrs.into(),
pat,
guard,
body,
Expand Down Expand Up @@ -2170,7 +2170,7 @@ impl<'a> Parser<'a> {

Ok((
ast::Arm {
attrs,
attrs: attrs.into(),
pat,
guard,
body: expr,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ impl<'a> Parser<'a> {
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),
Expand Down Expand Up @@ -1286,7 +1286,7 @@ impl<'a> Parser<'a> {
ident: None,
id: DUMMY_NODE_ID,
ty,
attrs,
attrs: attrs.into(),
is_placeholder: false,
},
TrailingToken::MaybeComma,
Expand Down Expand Up @@ -1460,7 +1460,7 @@ impl<'a> Parser<'a> {
vis,
id: DUMMY_NODE_ID,
ty,
attrs,
attrs: attrs.into(),
is_placeholder: false,
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/rustfmt/src/types.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -776,7 +776,7 @@ impl Rewrite for ast::Ty {
);
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,
Expand All @@ -800,7 +800,7 @@ impl Rewrite for ast::Ty {
);
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,
Expand Down