mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Use AttrVec
for Arm
, FieldDef
, and Variant
This commit is contained in:
parent
9fef8d91b4
commit
4f8e0ebcc5
@ -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 => {}, _ => {} }`
|
||||
@ -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
|
||||
@ -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,
|
||||
|
@ -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));
|
||||
@ -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));
|
||||
@ -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]
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -2116,7 +2116,7 @@ impl<'a> Parser<'a> {
|
||||
let span = body.span;
|
||||
return Ok((
|
||||
ast::Arm {
|
||||
attrs,
|
||||
attrs: attrs.into(),
|
||||
pat,
|
||||
guard,
|
||||
body,
|
||||
@ -2170,7 +2170,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
Ok((
|
||||
ast::Arm {
|
||||
attrs,
|
||||
attrs: attrs.into(),
|
||||
pat,
|
||||
guard,
|
||||
body: expr,
|
||||
|
@ -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),
|
||||
@ -1286,7 +1286,7 @@ impl<'a> Parser<'a> {
|
||||
ident: None,
|
||||
id: DUMMY_NODE_ID,
|
||||
ty,
|
||||
attrs,
|
||||
attrs: attrs.into(),
|
||||
is_placeholder: false,
|
||||
},
|
||||
TrailingToken::MaybeComma,
|
||||
@ -1460,7 +1460,7 @@ impl<'a> Parser<'a> {
|
||||
vis,
|
||||
id: DUMMY_NODE_ID,
|
||||
ty,
|
||||
attrs,
|
||||
attrs: attrs.into(),
|
||||
is_placeholder: false,
|
||||
})
|
||||
}
|
||||
|
@ -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 @@ 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,
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user