]> git.lizzy.rs Git - rust.git/commitdiff
introduce 'type AttrVec'
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 3 Dec 2019 15:38:34 +0000 (16:38 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Fri, 20 Dec 2019 21:53:40 +0000 (22:53 +0100)
23 files changed:
src/librustc/hir/lowering.rs
src/librustc/hir/lowering/expr.rs
src/librustc/hir/lowering/item.rs
src/librustc/hir/mod.rs
src/librustc_interface/util.rs
src/librustc_parse/parser/diagnostics.rs
src/librustc_parse/parser/expr.rs
src/librustc_parse/parser/item.rs
src/librustc_parse/parser/mod.rs
src/librustc_parse/parser/pat.rs
src/librustc_parse/parser/path.rs
src/librustc_parse/parser/stmt.rs
src/libsyntax/ast.rs
src/libsyntax/attr/mod.rs
src/libsyntax/lib.rs
src/libsyntax/mut_visit.rs
src/libsyntax_expand/base.rs
src/libsyntax_expand/build.rs
src/libsyntax_expand/placeholders.rs
src/libsyntax_ext/asm.rs
src/libsyntax_ext/concat_idents.rs
src/libsyntax_ext/deriving/debug.rs
src/libsyntax_ext/deriving/generic/mod.rs

index 3f8085f2344b3228ed57c659da4d831ddc013a94..6b83788298e4d6a65b9bc4dee8cac189e51f1dee 100644 (file)
@@ -53,7 +53,6 @@
 use errors::Applicability;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_index::vec::IndexVec;
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_data_structures::sync::Lrc;
 
 use std::collections::BTreeMap;
@@ -1205,7 +1204,7 @@ fn lower_generic_arg(
                                 id: ty.id,
                                 kind: ExprKind::Path(qself.clone(), path.clone()),
                                 span: ty.span,
-                                attrs: ThinVec::new(),
+                                attrs: AttrVec::new(),
                             };
 
                             let ct = self.with_new_scopes(|this| {
@@ -2751,7 +2750,7 @@ fn lower_block(&mut self, b: &Block, targeted_by_break: bool) -> P<hir::Block> {
     /// has no attributes and is not targeted by a `break`.
     fn lower_block_expr(&mut self, b: &Block) -> hir::Expr {
         let block = self.lower_block(b, false);
-        self.expr_block(block, ThinVec::new())
+        self.expr_block(block, AttrVec::new())
     }
 
     fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
@@ -3102,7 +3101,7 @@ fn stmt_expr(&mut self, span: Span, expr: hir::Expr) -> hir::Stmt {
 
     fn stmt_let_pat(
         &mut self,
-        attrs: ThinVec<Attribute>,
+        attrs: AttrVec,
         span: Span,
         init: Option<P<hir::Expr>>,
         pat: P<hir::Pat>,
index f8465baeb1305e917a1b4757f2b173fa3163beb0..04031710dc5ea30e99285a573552af478390e936 100644 (file)
@@ -1318,8 +1318,7 @@ pub(super) fn expr_drop_temps(
         &mut self,
         span: Span,
         expr: P<hir::Expr>,
-        attrs: ThinVec<Attribute>
-    ) -> hir::Expr {
+        attrs: AttrVec) -> hir::Expr {
         self.expr(span, hir::ExprKind::DropTemps(expr), attrs)
     }
 
@@ -1333,7 +1332,7 @@ fn expr_match(
         self.expr(span, hir::ExprKind::Match(arg, arms, source), ThinVec::new())
     }
 
-    fn expr_break(&mut self, span: Span, attrs: ThinVec<Attribute>) -> P<hir::Expr> {
+    fn expr_break(&mut self, span: Span, attrs: AttrVec) -> P<hir::Expr> {
         let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None);
         P(self.expr(span, expr_break, attrs))
     }
@@ -1404,7 +1403,7 @@ fn expr_std_path(
         span: Span,
         components: &[Symbol],
         params: Option<P<hir::GenericArgs>>,
-        attrs: ThinVec<Attribute>,
+        attrs: AttrVec,
     ) -> hir::Expr {
         let path = self.std_path(span, components, params, true);
         self.expr(
@@ -1423,7 +1422,7 @@ fn expr_ident_with_attrs(
         span: Span,
         ident: Ident,
         binding: hir::HirId,
-        attrs: ThinVec<Attribute>,
+        attrs: AttrVec,
     ) -> hir::Expr {
         let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
             None,
@@ -1459,16 +1458,11 @@ fn expr_block_empty(&mut self, span: Span) -> hir::Expr {
         self.expr_block(P(blk), ThinVec::new())
     }
 
-    pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: ThinVec<Attribute>) -> hir::Expr {
+    pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: AttrVec) -> hir::Expr {
         self.expr(b.span, hir::ExprKind::Block(b, None), attrs)
     }
 
-    pub(super) fn expr(
-        &mut self,
-        span: Span,
-        kind: hir::ExprKind,
-        attrs: ThinVec<Attribute>
-    ) -> hir::Expr {
+    pub(super) fn expr(&mut self, span: Span, kind: hir::ExprKind, attrs: AttrVec) -> hir::Expr {
         hir::Expr { hir_id: self.next_id(), kind, span, attrs }
     }
 
index 46c944fa67881c4ae46546887f29bb07575727aa..6cae8e2cc04e19941d0fa0438334aea8badd690d 100644 (file)
@@ -11,7 +11,6 @@
 use crate::hir::def::{Res, DefKind};
 use crate::util::nodemap::NodeMap;
 
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_target::spec::abi;
 
 use std::collections::BTreeSet;
@@ -899,7 +898,7 @@ fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
 
     /// Construct `ExprKind::Err` for the given `span`.
     fn expr_err(&mut self, span: Span) -> hir::Expr {
-        self.expr(span, hir::ExprKind::Err, ThinVec::new())
+        self.expr(span, hir::ExprKind::Err, AttrVec::new())
     }
 
     fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem {
@@ -1182,7 +1181,7 @@ fn lower_maybe_async_body(
                 //
                 // If this is the simple case, this parameter will end up being the same as the
                 // original parameter, but with a different pattern id.
-                let mut stmt_attrs = ThinVec::new();
+                let mut stmt_attrs = AttrVec::new();
                 stmt_attrs.extend(parameter.attrs.iter().cloned());
                 let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
                 let new_parameter = hir::Param {
@@ -1226,7 +1225,7 @@ fn lower_maybe_async_body(
                         desugared_span, ident, hir::BindingAnnotation::Mutable);
                     let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
                     let move_stmt = this.stmt_let_pat(
-                        ThinVec::new(),
+                        AttrVec::new(),
                         desugared_span,
                         Some(P(move_expr)),
                         move_pat,
@@ -1271,7 +1270,7 @@ fn lower_maybe_async_body(
                     let user_body = this.expr_drop_temps(
                         desugared_span,
                         P(user_body),
-                        ThinVec::new(),
+                        AttrVec::new(),
                     );
 
                     // As noted above, create the final block like
@@ -1288,9 +1287,9 @@ fn lower_maybe_async_body(
                         statements.into(),
                         Some(P(user_body)),
                     );
-                    this.expr_block(P(body), ThinVec::new())
+                    this.expr_block(P(body), AttrVec::new())
                 });
-            (HirVec::from(parameters), this.expr(body_span, async_expr, ThinVec::new()))
+            (HirVec::from(parameters), this.expr(body_span, async_expr, AttrVec::new()))
         })
     }
 
index 6b354b01518eab02d9d6e90279c61f0f4a97f69a..17f4ec3444175e6f84447d9319b35706d7d08481 100644 (file)
@@ -20,7 +20,7 @@
 use syntax_pos::{Span, DUMMY_SP, MultiSpan};
 use syntax::source_map::Spanned;
 use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
-use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
+use syntax::ast::{AttrVec, Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
 pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy};
 pub use syntax::ast::{IsAuto, ImplPolarity, BorrowKind};
 use syntax::attr::{InlineAttr, OptimizeAttr};
@@ -29,7 +29,6 @@
 use syntax::util::parser::ExprPrecedence;
 use rustc_target::spec::abi::Abi;
 use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_macros::HashStable;
 use rustc_serialize::{self, Encoder, Encodable, Decoder, Decodable};
 use std::collections::{BTreeSet, BTreeMap};
@@ -1274,7 +1273,7 @@ pub struct Local {
     pub init: Option<P<Expr>>,
     pub hir_id: HirId,
     pub span: Span,
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
     /// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
     /// desugaring. Otherwise will be `Normal`.
     pub source: LocalSource,
@@ -1459,7 +1458,7 @@ pub struct AnonConst {
 pub struct Expr {
     pub hir_id: HirId,
     pub kind: ExprKind,
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
     pub span: Span,
 }
 
index 4d686fc310f4ae25409588f07ed3e09be60cd16e..a8800082c9a734d7d4957fbbed80e2306a6431e4 100644 (file)
@@ -10,7 +10,6 @@
 use rustc_data_structures::sync::{Lock, Lrc};
 use rustc_data_structures::stable_hasher::StableHasher;
 use rustc_data_structures::fingerprint::Fingerprint;
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_data_structures::fx::{FxHashSet, FxHashMap};
 use rustc_errors::registry::Registry;
 use rustc_metadata::dynamic_lib::DynamicLibrary;
@@ -24,7 +23,7 @@
 use smallvec::SmallVec;
 use syntax::ptr::P;
 use syntax::mut_visit::{*, MutVisitor, visit_clobber};
-use syntax::ast::BlockCheckMode;
+use syntax::ast::{AttrVec, BlockCheckMode};
 use syntax::util::lev_distance::find_best_match_for_name;
 use syntax::source_map::{FileLoader, RealFileLoader, SourceMap};
 use syntax::symbol::{Symbol, sym};
@@ -741,7 +740,7 @@ fn block_to_stmt(b: ast::Block, resolver: &mut Resolver<'_>) -> ast::Stmt {
                 id: resolver.next_node_id(),
                 kind: ast::ExprKind::Block(P(b), None),
                 span: syntax_pos::DUMMY_SP,
-                attrs: ThinVec::new(),
+                attrs: AttrVec::new(),
             });
 
             ast::Stmt {
@@ -756,7 +755,7 @@ fn block_to_stmt(b: ast::Block, resolver: &mut Resolver<'_>) -> ast::Stmt {
             kind: ast::ExprKind::Loop(P(empty_block), None),
             id: self.resolver.next_node_id(),
             span: syntax_pos::DUMMY_SP,
-                attrs: ThinVec::new(),
+                attrs: AttrVec::new(),
         });
 
         let loop_stmt = ast::Stmt {
index cea17e4d0061dbe3b1363b1823594e8bcf971f98..16daefd1450ab70f34dd1c651e352f0d9b4177e6 100644 (file)
@@ -4,11 +4,10 @@
 use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
 use rustc_error_codes::*;
 use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
-use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind, Attribute};
+use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind, AttrVec};
 use syntax::token::{self, TokenKind, token_can_begin_expr};
 use syntax::print::pprust;
 use syntax::ptr::P;
-use syntax::ThinVec;
 use syntax::util::parser::AssocOp;
 use syntax::struct_span_err;
 use syntax_pos::symbol::kw;
@@ -32,7 +31,7 @@ pub(super) fn dummy_arg(ident: Ident) -> Param {
         id: ast::DUMMY_NODE_ID
     };
     Param {
-        attrs: ThinVec::default(),
+        attrs: AttrVec::default(),
         id: ast::DUMMY_NODE_ID,
         pat,
         span: ident.span,
@@ -164,7 +163,7 @@ fn recovered(qself: Option<QSelf>, path: ast::Path) -> Self {
         Self {
             span: path.span,
             kind: ExprKind::Path(qself, path),
-            attrs: ThinVec::new(),
+            attrs: AttrVec::new(),
             id: ast::DUMMY_NODE_ID,
         }
     }
@@ -551,7 +550,7 @@ pub(super) fn check_no_chained_comparison(
         );
 
         let mk_err_expr = |this: &Self, span| {
-            Ok(Some(this.mk_expr(span, ExprKind::Err, ThinVec::new())))
+            Ok(Some(this.mk_expr(span, ExprKind::Err, AttrVec::new())))
         };
 
         match lhs.kind {
@@ -974,7 +973,7 @@ pub(super) fn recover_incorrect_await_syntax(
         &mut self,
         lo: Span,
         await_sp: Span,
-        attrs: ThinVec<Attribute>,
+        attrs: AttrVec,
     ) -> PResult<'a, P<Expr>> {
         let (hi, expr, is_question) = if self.token == token::Not {
             // Handle `await!(<expr>)`.
@@ -1005,7 +1004,7 @@ fn recover_await_prefix(&mut self, await_sp: Span) -> PResult<'a, (Span, P<Expr>
                 None,
                 self.token.span,
                 BlockCheckMode::Default,
-                ThinVec::new(),
+                AttrVec::new(),
             )
         } else {
             self.parse_expr()
@@ -1126,7 +1125,7 @@ pub(super) fn recover_seq_parse_error(
                 err.emit();
                 // Recover from parse error, callers expect the closing delim to be consumed.
                 self.consume_block(delim, ConsumeClosingDelim::Yes);
-                self.mk_expr(lo.to(self.prev_span), ExprKind::Err, ThinVec::new())
+                self.mk_expr(lo.to(self.prev_span), ExprKind::Err, AttrVec::new())
             }
         }
     }
index 4edfbc4ec9ff0029fd0756ab16c58b48d75b66a7..7afa3d665d695a78132f86ad6c0c363cc3b16b06 100644 (file)
@@ -4,11 +4,10 @@
 use super::diagnostics::Error;
 use crate::maybe_recover_from_interpolated_ty_qpath;
 
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_errors::{PResult, Applicability};
-use syntax::ast::{self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
-use syntax::ast::{Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind};
-use syntax::ast::{FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit};
+use syntax::ast::{self, DUMMY_NODE_ID, AttrVec, AttrStyle, Ident, CaptureBy, Field, Lit};
+use syntax::ast::{BlockCheckMode, Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm};
+use syntax::ast::{Ty, TyKind, FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst};
 use syntax::token::{self, Token, TokenKind};
 use syntax::print::pprust;
 use syntax::ptr::P;
@@ -37,14 +36,14 @@ macro_rules! maybe_whole_expr {
                     let path = path.clone();
                     $p.bump();
                     return Ok($p.mk_expr(
-                        $p.token.span, ExprKind::Path(None, path), ThinVec::new()
+                        $p.token.span, ExprKind::Path(None, path), AttrVec::new()
                     ));
                 }
                 token::NtBlock(block) => {
                     let block = block.clone();
                     $p.bump();
                     return Ok($p.mk_expr(
-                        $p.token.span, ExprKind::Block(block, None), ThinVec::new()
+                        $p.token.span, ExprKind::Block(block, None), AttrVec::new()
                     ));
                 }
                 // N.B., `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
@@ -57,16 +56,16 @@ macro_rules! maybe_whole_expr {
 #[derive(Debug)]
 pub(super) enum LhsExpr {
     NotYetParsed,
-    AttributesParsed(ThinVec<Attribute>),
+    AttributesParsed(AttrVec),
     AlreadyParsed(P<Expr>),
 }
 
-impl From<Option<ThinVec<Attribute>>> for LhsExpr {
+impl From<Option<AttrVec>> for LhsExpr {
     /// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)`
     /// and `None` into `LhsExpr::NotYetParsed`.
     ///
     /// This conversion does not allocate.
-    fn from(o: Option<ThinVec<Attribute>>) -> Self {
+    fn from(o: Option<AttrVec>) -> Self {
         if let Some(attrs) = o {
             LhsExpr::AttributesParsed(attrs)
         } else {
@@ -103,7 +102,7 @@ fn parse_expr_catch_underscore(&mut self) -> PResult<'a, P<Expr>> {
                     err.emit();
                     let sp = self.token.span;
                     self.bump();
-                    Ok(self.mk_expr(sp, ExprKind::Err, ThinVec::new()))
+                    Ok(self.mk_expr(sp, ExprKind::Err, AttrVec::new()))
                 }
                 _ => Err(err),
             },
@@ -122,7 +121,7 @@ fn parse_paren_expr_seq(&mut self) -> PResult<'a, Vec<P<Expr>>> {
     pub(super) fn parse_expr_res(
         &mut self,
         r: Restrictions,
-        already_parsed_attrs: Option<ThinVec<Attribute>>
+        already_parsed_attrs: Option<AttrVec>
     ) -> PResult<'a, P<Expr>> {
         self.with_res(r, |this| this.parse_assoc_expr(already_parsed_attrs))
     }
@@ -134,7 +133,7 @@ pub(super) fn parse_expr_res(
     #[inline]
     fn parse_assoc_expr(
         &mut self,
-        already_parsed_attrs: Option<ThinVec<Attribute>>,
+        already_parsed_attrs: Option<AttrVec>,
     ) -> PResult<'a, P<Expr>> {
         self.parse_assoc_expr_with(0, already_parsed_attrs.into())
     }
@@ -237,7 +236,7 @@ pub(super) fn parse_assoc_expr_with(
                 };
 
                 let r = self.mk_range(Some(lhs), rhs, limits)?;
-                lhs = self.mk_expr(lhs_span.to(rhs_span), r, ThinVec::new());
+                lhs = self.mk_expr(lhs_span.to(rhs_span), r, AttrVec::new());
                 break
             }
 
@@ -271,9 +270,9 @@ pub(super) fn parse_assoc_expr_with(
                 AssocOp::Greater | AssocOp::GreaterEqual => {
                     let ast_op = op.to_ast_binop().unwrap();
                     let binary = self.mk_binary(source_map::respan(cur_op_span, ast_op), lhs, rhs);
-                    self.mk_expr(span, binary, ThinVec::new())
+                    self.mk_expr(span, binary, AttrVec::new())
                 }
-                AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs), ThinVec::new()),
+                AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs), AttrVec::new()),
                 AssocOp::AssignOp(k) => {
                     let aop = match k {
                         token::Plus =>    BinOpKind::Add,
@@ -288,7 +287,7 @@ pub(super) fn parse_assoc_expr_with(
                         token::Shr =>     BinOpKind::Shr,
                     };
                     let aopexpr = self.mk_assign_op(source_map::respan(cur_op_span, aop), lhs, rhs);
-                    self.mk_expr(span, aopexpr, ThinVec::new())
+                    self.mk_expr(span, aopexpr, AttrVec::new())
                 }
                 AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotEq => {
                     self.bug("AssocOp should have been handled by special case")
@@ -398,7 +397,7 @@ fn is_at_start_of_range_notation_rhs(&self) -> bool {
     /// Parses prefix-forms of range notation: `..expr`, `..`, `..=expr`.
     fn parse_prefix_range_expr(
         &mut self,
-        already_parsed_attrs: Option<ThinVec<Attribute>>
+        already_parsed_attrs: Option<AttrVec>
     ) -> PResult<'a, P<Expr>> {
         // Check for deprecated `...` syntax.
         if self.token == token::DotDotDot {
@@ -435,10 +434,7 @@ fn parse_prefix_range_expr(
     }
 
     /// Parses a prefix-unary-operator expr.
-    fn parse_prefix_expr(
-        &mut self,
-        already_parsed_attrs: Option<ThinVec<Attribute>>
-    ) -> PResult<'a, P<Expr>> {
+    fn parse_prefix_expr(&mut self, already_parsed_attrs: Option<AttrVec>) -> PResult<'a, P<Expr>> {
         let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?;
         let lo = self.token.span;
         // Note: when adding new unary operators, don't forget to adjust TokenKind::can_begin_expr()
@@ -549,7 +545,7 @@ fn parse_assoc_op_cast(&mut self, lhs: P<Expr>, lhs_span: Span,
                            expr_kind: fn(P<Expr>, P<Ty>) -> ExprKind)
                            -> PResult<'a, P<Expr>> {
         let mk_expr = |this: &mut Self, rhs: P<Ty>| {
-            this.mk_expr(lhs_span.to(rhs.span), expr_kind(lhs, rhs), ThinVec::new())
+            this.mk_expr(lhs_span.to(rhs.span), expr_kind(lhs, rhs), AttrVec::new())
         };
 
         // Save the state of the parser before parsing type normally, in case there is a
@@ -650,7 +646,7 @@ fn parse_address_of(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> {
     /// Parses `a.b` or `a(13)` or `a[4]` or just `a`.
     fn parse_dot_or_call_expr(
         &mut self,
-        already_parsed_attrs: Option<ThinVec<Attribute>>,
+        already_parsed_attrs: Option<AttrVec>,
     ) -> PResult<'a, P<Expr>> {
         let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?;
 
@@ -663,7 +659,7 @@ pub(super) fn parse_dot_or_call_expr_with(
         &mut self,
         e0: P<Expr>,
         lo: Span,
-        mut attrs: ThinVec<Attribute>,
+        mut attrs: AttrVec,
     ) -> PResult<'a, P<Expr>> {
         // Stitch the list of outer attributes onto the return value.
         // A little bit ugly, but the best way given the current code
@@ -692,7 +688,7 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
             // expr?
             while self.eat(&token::Question) {
                 let hi = self.prev_span;
-                e = self.mk_expr(lo.to(hi), ExprKind::Try(e), ThinVec::new());
+                e = self.mk_expr(lo.to(hi), ExprKind::Try(e), AttrVec::new());
             }
 
             // expr.f
@@ -705,7 +701,7 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
                         let span = self.token.span;
                         self.bump();
                         let field = ExprKind::Field(e, Ident::new(symbol, span));
-                        e = self.mk_expr(lo.to(span), field, ThinVec::new());
+                        e = self.mk_expr(lo.to(span), field, AttrVec::new());
 
                         self.expect_no_suffix(span, "a tuple index", suffix);
                     }
@@ -754,7 +750,7 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
                     let seq = self.parse_paren_expr_seq().map(|es| {
                         let nd = self.mk_call(e, es);
                         let hi = self.prev_span;
-                        self.mk_expr(lo.to(hi), nd, ThinVec::new())
+                        self.mk_expr(lo.to(hi), nd, AttrVec::new())
                     });
                     e = self.recover_seq_parse_error(token::Paren, lo, seq);
                 }
@@ -767,7 +763,7 @@ fn parse_dot_or_call_expr_with_(&mut self, e0: P<Expr>, lo: Span) -> PResult<'a,
                     hi = self.token.span;
                     self.expect(&token::CloseDelim(token::Bracket))?;
                     let index = self.mk_index(e, ix);
-                    e = self.mk_expr(lo.to(hi), index, ThinVec::new())
+                    e = self.mk_expr(lo.to(hi), index, AttrVec::new())
                 }
                 _ => return Ok(e)
             }
@@ -791,7 +787,7 @@ fn parse_dot_suffix(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Exp
                 args.insert(0, self_arg);
 
                 let span = lo.to(self.prev_span);
-                self.mk_expr(span, ExprKind::MethodCall(segment, args), ThinVec::new())
+                self.mk_expr(span, ExprKind::MethodCall(segment, args), AttrVec::new())
             }
             _ => {
                 // Field access `expr.f`
@@ -801,7 +797,7 @@ fn parse_dot_suffix(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Exp
                 }
 
                 let span = lo.to(self.prev_span);
-                self.mk_expr(span, ExprKind::Field(self_arg, segment.ident), ThinVec::new())
+                self.mk_expr(span, ExprKind::Field(self_arg, segment.ident), AttrVec::new())
             }
         })
     }
@@ -820,7 +816,7 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
         //
         // Therefore, prevent sub-parser from parsing
         // attributes by giving them a empty "already-parsed" list.
-        let attrs = ThinVec::new();
+        let attrs = AttrVec::new();
 
         // Note: when adding new syntax here, don't forget to adjust `TokenKind::can_begin_expr()`.
         let lo = self.token.span;
@@ -909,7 +905,7 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
         }
     }
 
-    fn parse_lit_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_lit_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
         match self.parse_opt_lit() {
             Some(literal) => {
@@ -920,7 +916,7 @@ fn parse_lit_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>>
         }
     }
 
-    fn parse_tuple_parens_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_tuple_parens_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
         let mut first = true;
         let parse_leading_attr_expr = |p: &mut Self| {
@@ -947,10 +943,7 @@ fn parse_tuple_parens_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<
         self.maybe_recover_from_bad_qpath(expr, true)
     }
 
-    fn parse_array_or_repeat_expr(
-        &mut self,
-        mut attrs: ThinVec<Attribute>,
-    ) -> PResult<'a, P<Expr>> {
+    fn parse_array_or_repeat_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
         self.bump(); // `[`
 
@@ -990,7 +983,7 @@ fn parse_array_or_repeat_expr(
         self.maybe_recover_from_bad_qpath(expr, true)
     }
 
-    fn parse_path_start_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_path_start_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
         let path = self.parse_path(PathStyle::Expr)?;
 
@@ -1017,11 +1010,7 @@ fn parse_path_start_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<
         self.maybe_recover_from_bad_qpath(expr, true)
     }
 
-    fn parse_labeled_expr(
-        &mut self,
-        label: Label,
-        attrs: ThinVec<Attribute>,
-    ) -> PResult<'a, P<Expr>> {
+    fn parse_labeled_expr(&mut self, label: Label, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = label.ident.span;
         self.expect(&token::Colon)?;
         if self.eat_keyword(kw::While) {
@@ -1046,7 +1035,7 @@ fn parse_labeled_expr(
     }
 
     /// Recover on the syntax `do catch { ... }` suggesting `try { ... }` instead.
-    fn recover_do_catch(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn recover_do_catch(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
 
         self.bump(); // `do`
@@ -1076,7 +1065,7 @@ fn parse_expr_opt(&mut self) -> PResult<'a, Option<P<Expr>>> {
     }
 
     /// Parse `"return" expr?`.
-    fn parse_return_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_return_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.prev_span;
         let kind = ExprKind::Ret(self.parse_expr_opt()?);
         let expr = self.mk_expr(lo.to(self.prev_span), kind, attrs);
@@ -1084,7 +1073,7 @@ fn parse_return_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr
     }
 
     /// Parse `"('label ":")? break expr?`.
-    fn parse_break_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_break_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.prev_span;
         let label = self.eat_label();
         let kind = if self.token != token::OpenDelim(token::Brace)
@@ -1099,7 +1088,7 @@ fn parse_break_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>
     }
 
     /// Parse `"yield" expr?`.
-    fn parse_yield_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_yield_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.prev_span;
         let kind = ExprKind::Yield(self.parse_expr_opt()?);
         let span = lo.to(self.prev_span);
@@ -1307,12 +1296,12 @@ pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
         let literal = self.parse_lit()?;
         let hi = self.prev_span;
-        let expr = self.mk_expr(lo.to(hi), ExprKind::Lit(literal), ThinVec::new());
+        let expr = self.mk_expr(lo.to(hi), ExprKind::Lit(literal), AttrVec::new());
 
         if minus_present {
             let minus_hi = self.prev_span;
             let unary = self.mk_unary(UnOp::Neg, expr);
-            Ok(self.mk_expr(minus_lo.to(minus_hi), unary, ThinVec::new()))
+            Ok(self.mk_expr(minus_lo.to(minus_hi), unary, AttrVec::new()))
         } else {
             Ok(expr)
         }
@@ -1324,7 +1313,7 @@ pub(super) fn parse_block_expr(
         opt_label: Option<Label>,
         lo: Span,
         blk_mode: BlockCheckMode,
-        outer_attrs: ThinVec<Attribute>,
+        outer_attrs: AttrVec,
     ) -> PResult<'a, P<Expr>> {
         if let Some(label) = opt_label {
             self.sess.gated_spans.gate(sym::label_break_value, label.ident.span);
@@ -1340,7 +1329,7 @@ pub(super) fn parse_block_expr(
     }
 
     /// Parses a closure expression (e.g., `move |args| expr`).
-    fn parse_closure_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_closure_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.token.span;
 
         let movability = if self.eat_keyword(kw::Static) {
@@ -1370,7 +1359,7 @@ fn parse_closure_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Exp
             _ => {
                 // If an explicit return type is given, require a block to appear (RFC 968).
                 let body_lo = self.token.span;
-                self.parse_block_expr(None, body_lo, BlockCheckMode::Default, ThinVec::new())?
+                self.parse_block_expr(None, body_lo, BlockCheckMode::Default, AttrVec::new())?
             }
         };
 
@@ -1440,7 +1429,7 @@ fn parse_fn_block_param(&mut self) -> PResult<'a, Param> {
     }
 
     /// Parses an `if` expression (`if` token already eaten).
-    fn parse_if_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_if_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.prev_span;
         let cond = self.parse_cond_expr()?;
 
@@ -1486,7 +1475,7 @@ fn parse_cond_expr(&mut self) -> PResult<'a, P<Expr>> {
 
     /// Parses a `let $pat = $expr` pseudo-expression.
     /// The `let` token has already been eaten.
-    fn parse_let_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_let_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let lo = self.prev_span;
         let pat = self.parse_top_pat(GateOr::No)?;
         self.expect(&token::Eq)?;
@@ -1502,10 +1491,10 @@ fn parse_let_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>>
     /// Parses an `else { ... }` expression (`else` token already eaten).
     fn parse_else_expr(&mut self) -> PResult<'a, P<Expr>> {
         if self.eat_keyword(kw::If) {
-            return self.parse_if_expr(ThinVec::new());
+            return self.parse_if_expr(AttrVec::new());
         } else {
             let blk = self.parse_block()?;
-            return Ok(self.mk_expr(blk.span, ExprKind::Block(blk, None), ThinVec::new()));
+            return Ok(self.mk_expr(blk.span, ExprKind::Block(blk, None), AttrVec::new()));
         }
     }
 
@@ -1514,7 +1503,7 @@ fn parse_for_expr(
         &mut self,
         opt_label: Option<Label>,
         span_lo: Span,
-        mut attrs: ThinVec<Attribute>
+        mut attrs: AttrVec
     ) -> PResult<'a, P<Expr>> {
         // Parse: `for <src_pat> in <src_expr> <src_loop_block>`
 
@@ -1556,7 +1545,7 @@ fn parse_while_expr(
         &mut self,
         opt_label: Option<Label>,
         span_lo: Span,
-        mut attrs: ThinVec<Attribute>
+        mut attrs: AttrVec
     ) -> PResult<'a, P<Expr>> {
         let cond = self.parse_cond_expr()?;
         let (iattrs, body) = self.parse_inner_attrs_and_block()?;
@@ -1570,7 +1559,7 @@ fn parse_loop_expr(
         &mut self,
         opt_label: Option<Label>,
         span_lo: Span,
-        mut attrs: ThinVec<Attribute>
+        mut attrs: AttrVec
     ) -> PResult<'a, P<Expr>> {
         let (iattrs, body) = self.parse_inner_attrs_and_block()?;
         attrs.extend(iattrs);
@@ -1589,7 +1578,7 @@ fn eat_label(&mut self) -> Option<Label> {
     }
 
     /// Parses a `match ... { ... }` expression (`match` token already eaten).
-    fn parse_match_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_match_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let match_span = self.prev_span;
         let lo = self.prev_span;
         let discriminant = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
@@ -1701,11 +1690,7 @@ pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
     }
 
     /// Parses a `try {...}` expression (`try` token already eaten).
-    fn parse_try_block(
-        &mut self,
-        span_lo: Span,
-        mut attrs: ThinVec<Attribute>
-    ) -> PResult<'a, P<Expr>> {
+    fn parse_try_block(&mut self, span_lo: Span, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let (iattrs, body) = self.parse_inner_attrs_and_block()?;
         attrs.extend(iattrs);
         if self.eat_keyword(kw::Catch) {
@@ -1737,7 +1722,7 @@ fn is_try_block(&self) -> bool {
     }
 
     /// Parses an `async move? {...}` expression.
-    fn parse_async_block(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
+    fn parse_async_block(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         let span_lo = self.token.span;
         self.expect_keyword(kw::Async)?;
         let capture_clause = self.parse_capture_clause();
@@ -1764,7 +1749,7 @@ fn maybe_parse_struct_expr(
         &mut self,
         lo: Span,
         path: &ast::Path,
-        attrs: &ThinVec<Attribute>,
+        attrs: &AttrVec,
     ) -> Option<PResult<'a, P<Expr>>> {
         let struct_allowed = !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL);
         let certainly_not_a_block = || self.look_ahead(1, |t| t.is_ident()) && (
@@ -1805,7 +1790,7 @@ pub(super) fn parse_struct_expr(
         &mut self,
         lo: Span,
         pth: ast::Path,
-        mut attrs: ThinVec<Attribute>
+        mut attrs: AttrVec
     ) -> PResult<'a, P<Expr>> {
         let struct_sp = lo.to(self.prev_span);
         self.bump();
@@ -1851,9 +1836,9 @@ pub(super) fn parse_struct_expr(
                     recovery_field = Some(ast::Field {
                         ident: Ident::new(name, self.token.span),
                         span: self.token.span,
-                        expr: self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()),
+                        expr: self.mk_expr(self.token.span, ExprKind::Err, AttrVec::new()),
                         is_shorthand: false,
-                        attrs: ThinVec::new(),
+                        attrs: AttrVec::new(),
                         id: DUMMY_NODE_ID,
                         is_placeholder: false,
                     });
@@ -1932,7 +1917,7 @@ fn parse_field(&mut self) -> PResult<'a, Field> {
 
             // Mimic `x: x` for the `x` field shorthand.
             let path = ast::Path::from_ident(fieldname);
-            let expr = self.mk_expr(fieldname.span, ExprKind::Path(None, path), ThinVec::new());
+            let expr = self.mk_expr(fieldname.span, ExprKind::Path(None, path), AttrVec::new());
             (fieldname, expr, true)
         };
         Ok(ast::Field {
@@ -2009,16 +1994,16 @@ fn mk_call(&self, f: P<Expr>, args: Vec<P<Expr>>) -> ExprKind {
 
     fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
         let span = lo.to(self.prev_span);
-        let await_expr = self.mk_expr(span, ExprKind::Await(self_arg), ThinVec::new());
+        let await_expr = self.mk_expr(span, ExprKind::Await(self_arg), AttrVec::new());
         self.recover_from_await_method_call();
         Ok(await_expr)
     }
 
-    crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
+    crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: AttrVec) -> P<Expr> {
         P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
     }
 
     pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {
-        self.mk_expr(span, ExprKind::Err, ThinVec::new())
+        self.mk_expr(span, ExprKind::Err, AttrVec::new())
     }
 }
index 0840a1551dbf4fd1da7c909b365efca5d2b07273..229ca07f13b51a4063610e4249f36c257b7ec986 100644 (file)
@@ -5,15 +5,14 @@
 
 use rustc_errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
 use rustc_error_codes::*;
-use syntax::ast::{self, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item};
-use syntax::ast::{AssocItem, AssocItemKind, ItemKind, UseTree, UseTreeKind};
+use syntax::ast::{self, DUMMY_NODE_ID, Ident, AttrVec, Attribute, AttrKind, AttrStyle, AnonConst};
+use syntax::ast::{AssocItem, AssocItemKind, Item, ItemKind, UseTree, UseTreeKind};
 use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
 use syntax::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
 use syntax::ast::{Ty, TyKind, Generics, TraitRef, EnumDef, Variant, VariantData, StructField};
 use syntax::ast::{Mac, MacArgs, MacDelimiter, Block, BindingMode, FnDecl, FnSig, SelfKind, Param};
 use syntax::print::pprust;
 use syntax::ptr::P;
-use syntax::ThinVec;
 use syntax::token;
 use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
 use syntax::struct_span_err;
@@ -2095,7 +2094,7 @@ fn parse_self_param(&mut self) -> PResult<'a, Option<Param>> {
         };
 
         let eself = source_map::respan(eself_lo.to(eself_hi), eself);
-        Ok(Some(Param::from_self(ThinVec::default(), eself, eself_ident)))
+        Ok(Some(Param::from_self(AttrVec::default(), eself, eself_ident)))
     }
 
     fn is_named_param(&self) -> bool {
index 07e99cfe01292cab7ed680b28ebe1f50d019f711..938c2d89857db823e3a2b380a7891c1a1809332d 100644 (file)
@@ -15,9 +15,8 @@
 use crate::lexer::UnmatchedBrace;
 
 use rustc_errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
-use rustc_data_structures::thin_vec::ThinVec;
-use syntax::ast::{self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit};
-use syntax::ast::{IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety};
+use syntax::ast::{self, DUMMY_NODE_ID, AttrVec, AttrStyle, CrateSugar, Extern, Ident, Unsafety};
+use syntax::ast::{StrLit, IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind};
 use syntax::print::pprust;
 use syntax::ptr::P;
 use syntax::token::{self, Token, TokenKind, DelimToken};
@@ -1054,8 +1053,8 @@ fn parse_mac_args_common(&mut self, delimited_only: bool) -> PResult<'a, MacArgs
 
     fn parse_or_use_outer_attributes(
         &mut self,
-        already_parsed_attrs: Option<ThinVec<Attribute>>,
-    ) -> PResult<'a, ThinVec<Attribute>> {
+        already_parsed_attrs: Option<AttrVec>,
+    ) -> PResult<'a, AttrVec> {
         if let Some(attrs) = already_parsed_attrs {
             Ok(attrs)
         } else {
index 117b92dc9a5746812fc000c943e4830fb6199223..593fb30bb752a540d779eb523130e820d299f75f 100644 (file)
@@ -1,12 +1,11 @@
 use super::{Parser, PathStyle};
 use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
 use rustc_errors::{PResult, Applicability, DiagnosticBuilder};
-use syntax::ast::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
+use syntax::ast::{self, AttrVec, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
 use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
 use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
 use syntax::ptr::P;
 use syntax::print::pprust;
-use syntax::ThinVec;
 use syntax::token;
 use syntax_pos::source_map::{respan, Span, Spanned};
 use syntax_pos::symbol::{kw, sym};
@@ -636,7 +635,7 @@ fn parse_pat_range_starting_with_path(
         let op_span = self.token.span;
         // Parse range
         let span = lo.to(self.prev_span);
-        let begin = self.mk_expr(span, ExprKind::Path(qself, path), ThinVec::new());
+        let begin = self.mk_expr(span, ExprKind::Path(qself, path), AttrVec::new());
         self.bump();
         let end = self.parse_pat_range_end_opt(&begin, form)?;
         Ok(PatKind::Range(begin, end, respan(op_span, end_kind)))
@@ -693,7 +692,7 @@ fn parse_pat_range_to(&mut self, re: RangeEnd, form: &str) -> PResult<'a, PatKin
         let lo = self.prev_span;
         let end = self.parse_pat_range_end()?;
         let range_span = lo.to(end.span);
-        let begin = self.mk_expr(range_span, ExprKind::Err, ThinVec::new());
+        let begin = self.mk_expr(range_span, ExprKind::Err, AttrVec::new());
 
         self.diagnostic()
             .struct_span_err(range_span, &format!("`{}X` range patterns are not supported", form))
@@ -731,7 +730,7 @@ fn parse_pat_range_end_opt(&mut self, begin: &Expr, form: &str) -> PResult<'a, P
                 )
                 .emit();
 
-            Ok(self.mk_expr(range_span, ExprKind::Err, ThinVec::new()))
+            Ok(self.mk_expr(range_span, ExprKind::Err, AttrVec::new()))
         }
     }
 
@@ -747,7 +746,7 @@ fn parse_pat_range_end(&mut self) -> PResult<'a, P<Expr>> {
                 (None, self.parse_path(PathStyle::Expr)?)
             };
             let hi = self.prev_span;
-            Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path), ThinVec::new()))
+            Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path), AttrVec::new()))
         } else {
             self.parse_literal_maybe_minus()
         }
index aeba6dd2f67c57fe5e5fd3cbe22a88da599c24d9..802d38e2997128b2b7dcd57ce2ad745d6ff20dd7 100644 (file)
@@ -3,7 +3,6 @@
 use rustc_errors::{PResult, Applicability, pluralize};
 use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
 use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
-use syntax::ThinVec;
 use syntax::token::{self, Token};
 use syntax_pos::source_map::{Span, BytePos};
 use syntax_pos::symbol::{kw, sym};
@@ -400,7 +399,7 @@ fn parse_generic_args(&mut self) -> PResult<'a, (Vec<GenericArg>, Vec<AssocTyCon
                 // Parse const argument.
                 let expr = if let token::OpenDelim(token::Brace) = self.token.kind {
                     self.parse_block_expr(
-                        None, self.token.span, BlockCheckMode::Default, ThinVec::new()
+                        None, self.token.span, BlockCheckMode::Default, ast::AttrVec::new()
                     )?
                 } else if self.token.is_ident() {
                     // FIXME(const_generics): to distinguish between idents for types and consts,
index 036badfe75d9fdd18af9c9b0a089a195d3115e50..a080806311613c861bb31c4475c3595013dbf9c8 100644 (file)
@@ -7,11 +7,10 @@
 use crate::DirectoryOwnership;
 
 use rustc_errors::{PResult, Applicability};
-use syntax::ThinVec;
 use syntax::ptr::P;
 use syntax::ast;
 use syntax::ast::{DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
-use syntax::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
+use syntax::ast::{AttrVec, Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
 use syntax::util::classify;
 use syntax::token;
 use syntax_pos::source_map::{respan, Span};
@@ -67,10 +66,10 @@ fn parse_stmt_without_recovery(
             }
 
             let expr = if self.check(&token::OpenDelim(token::Brace)) {
-                self.parse_struct_expr(lo, path, ThinVec::new())?
+                self.parse_struct_expr(lo, path, AttrVec::new())?
             } else {
                 let hi = self.prev_span;
-                self.mk_expr(lo.to(hi), ExprKind::Path(None, path), ThinVec::new())
+                self.mk_expr(lo.to(hi), ExprKind::Path(None, path), AttrVec::new())
             };
 
             let expr = self.with_res(Restrictions::STMT_EXPR, |this| {
@@ -104,7 +103,7 @@ fn parse_stmt_without_recovery(
             let kind = StmtKind::Semi(self.mk_expr(
                 lo.to(last_semi),
                 ExprKind::Tup(Vec::new()),
-                ThinVec::new()
+                AttrVec::new()
             ));
             return Ok(Some(self.mk_stmt(lo.to(last_semi), kind)));
         }
@@ -124,7 +123,7 @@ fn parse_stmt_without_recovery(
     fn parse_stmt_mac(
         &mut self,
         lo: Span,
-        attrs: ThinVec<Attribute>,
+        attrs: AttrVec,
         path: ast::Path,
         legacy_warnings: bool,
     ) -> PResult<'a, Option<Stmt>> {
@@ -169,7 +168,7 @@ fn parse_stmt_mac(
             StmtKind::Mac(P((mac, style, attrs)))
         } else {
             // Since none of the above applied, this is an expression statement macro.
-            let e = self.mk_expr(lo.to(hi), ExprKind::Mac(mac), ThinVec::new());
+            let e = self.mk_expr(lo.to(hi), ExprKind::Mac(mac), AttrVec::new());
             let e = self.maybe_recover_from_bad_qpath(e, true)?;
             let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?;
             let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
@@ -191,7 +190,7 @@ fn error_outer_attrs(&self, attrs: &[Attribute]) {
     }
 
     /// Parses a local variable declaration.
-    fn parse_local(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Local>> {
+    fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
         let lo = self.prev_span;
         let pat = self.parse_top_pat(GateOr::Yes)?;
 
index cf54fd2887af6018b5382da120e4b2581ad33051..c1458236788cb11b9f3b6a8b7b1b2c46dcd0a647 100644 (file)
@@ -338,7 +338,7 @@ pub enum GenericParamKind {
 pub struct GenericParam {
     pub id: NodeId,
     pub ident: Ident,
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
     pub bounds: GenericBounds,
     pub is_placeholder: bool,
     pub kind: GenericParamKind,
@@ -599,7 +599,7 @@ pub struct FieldPat {
     /// The pattern the field is destructured to
     pub pat: P<Pat>,
     pub is_shorthand: bool,
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
     pub id: NodeId,
     pub span: Span,
     pub is_placeholder: bool,
@@ -911,7 +911,7 @@ pub enum StmtKind {
     /// Expr with a trailing semi-colon.
     Semi(P<Expr>),
     /// Macro.
-    Mac(P<(Mac, MacStmtStyle, ThinVec<Attribute>)>),
+    Mac(P<(Mac, MacStmtStyle, AttrVec)>),
 }
 
 #[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
@@ -936,7 +936,7 @@ pub struct Local {
     /// Initializer expression to set the value, if any.
     pub init: Option<P<Expr>>,
     pub span: Span,
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
 }
 
 /// An arm of a 'match'.
@@ -966,7 +966,7 @@ pub struct Arm {
 /// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Field {
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
     pub id: NodeId,
     pub span: Span,
     pub ident: Ident,
@@ -1004,7 +1004,7 @@ pub struct Expr {
     pub id: NodeId,
     pub kind: ExprKind,
     pub span: Span,
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
 }
 
 // `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
@@ -1961,7 +1961,7 @@ pub struct InlineAsm {
 /// E.g., `bar: usize` as in `fn foo(bar: usize)`.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Param {
-    pub attrs: ThinVec<Attribute>,
+    pub attrs: AttrVec,
     pub ty: P<Ty>,
     pub pat: P<Pat>,
     pub id: NodeId,
@@ -2014,7 +2014,7 @@ pub fn is_self(&self) -> bool {
     }
 
     /// Builds a `Param` object from `ExplicitSelf`.
-    pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Ident) -> Param {
+    pub fn from_self(attrs: AttrVec, eself: ExplicitSelf, eself_ident: Ident) -> Param {
         let span = eself.span.to(eself_ident.span);
         let infer_ty = P(Ty {
             id: DUMMY_NODE_ID,
@@ -2332,6 +2332,9 @@ pub struct AttrItem {
     pub args: MacArgs,
 }
 
+/// A list of attributes.
+pub type AttrVec = ThinVec<Attribute>;
+
 /// Metadata associated with an item.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Attribute {
index 13a9ed5f215d239a3658b368c3fa9f0081be4222..ae6d50ba083074adb83af7fbaaa9d0b22fa347bb 100644 (file)
@@ -9,7 +9,7 @@
 pub use crate::ast::Attribute;
 
 use crate::ast;
-use crate::ast::{AttrItem, AttrId, AttrKind, AttrStyle, Name, Ident, Path, PathSegment};
+use crate::ast::{AttrVec, AttrItem, AttrId, AttrKind, AttrStyle, Name, Ident, Path, PathSegment};
 use crate::ast::{MacArgs, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem};
 use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam};
 use crate::mut_visit::visit_clobber;
@@ -17,7 +17,6 @@
 use crate::token::{self, Token};
 use crate::ptr::P;
 use crate::symbol::{sym, Symbol};
-use crate::ThinVec;
 use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
 use crate::GLOBALS;
 
@@ -665,7 +664,7 @@ fn visit_attrs<F: FnOnce(&mut Vec<Attribute>)>(&mut self, f: F) {
     }
 }
 
-impl HasAttrs for ThinVec<Attribute> {
+impl HasAttrs for AttrVec {
     fn attrs(&self) -> &[Attribute] {
         self
     }
index 36173801eae3d31dc760fcc5f869185ef0c2b938..30fd23ea909acb375cca7ff0d6fb97a210efa6bb 100644 (file)
@@ -24,7 +24,6 @@
 pub use errors;
 use rustc_data_structures::sync::Lock;
 use rustc_index::bit_set::GrowableBitSet;
-pub use rustc_data_structures::thin_vec::ThinVec;
 use ast::AttrId;
 use syntax_pos::edition::Edition;
 
index 2a6cff5971c57e0b8c5629f9750b613d2ddb1028..1d27f70f5a5443aa3d147024c1c668f4f534a48c 100644 (file)
@@ -11,7 +11,6 @@
 use crate::source_map::{Spanned, respan};
 use crate::token::{self, Token};
 use crate::ptr::P;
-use crate::ThinVec;
 use crate::tokenstream::*;
 use crate::util::map_in_place::MapInPlace;
 
@@ -337,7 +336,7 @@ pub fn visit_attrs<T: MutVisitor>(attrs: &mut Vec<Attribute>, vis: &mut T) {
 }
 
 // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
-pub fn visit_thin_attrs<T: MutVisitor>(attrs: &mut ThinVec<Attribute>, vis: &mut T) {
+pub fn visit_thin_attrs<T: MutVisitor>(attrs: &mut AttrVec, vis: &mut T) {
     for attr in attrs.iter_mut() {
         vis.visit_attribute(attr);
     }
index 75066a006bf3aaa0d7dbbbbf35f80f94b5f86900..2ad327e872e15f04cfc29c210b5641075640ba58 100644 (file)
@@ -9,7 +9,6 @@
 use syntax::ptr::P;
 use syntax::sess::ParseSess;
 use syntax::symbol::{kw, sym, Ident, Symbol};
-use syntax::ThinVec;
 use syntax::token;
 use syntax::tokenstream::{self, TokenStream};
 use syntax::visit::Visitor;
@@ -552,7 +551,7 @@ pub fn raw_expr(sp: Span, is_error: bool) -> P<ast::Expr> {
             id: ast::DUMMY_NODE_ID,
             kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) },
             span: sp,
-            attrs: ThinVec::new(),
+            attrs: ast::AttrVec::new(),
         })
     }
 
index 3d082101c41084e1d61cbeee6ac87ef14c94ba0c..4c539cad111a01ef3b60de6f8c07cb217ed3141c 100644 (file)
@@ -1,11 +1,10 @@
 use crate::base::ExtCtxt;
 
-use syntax::ast::{self, Ident, Expr, BlockCheckMode, UnOp, PatKind};
+use syntax::ast::{self, AttrVec, Ident, Expr, BlockCheckMode, UnOp, PatKind};
 use syntax::attr;
 use syntax::source_map::{respan, Spanned};
 use syntax::ptr::P;
 use syntax::symbol::{kw, sym, Symbol};
-use syntax::ThinVec;
 
 use syntax_pos::{Pos, Span};
 
@@ -81,7 +80,7 @@ pub fn anon_const(&self, span: Span, kind: ast::ExprKind) -> ast::AnonConst {
                 id: ast::DUMMY_NODE_ID,
                 kind,
                 span,
-                attrs: ThinVec::new(),
+                attrs: AttrVec::new(),
             })
         }
     }
@@ -190,7 +189,7 @@ pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
             init: Some(ex),
             id: ast::DUMMY_NODE_ID,
             span: sp,
-            attrs: ThinVec::new(),
+            attrs: AttrVec::new(),
         });
         ast::Stmt {
             id: ast::DUMMY_NODE_ID,
@@ -207,7 +206,7 @@ pub fn stmt_let_type_only(&self, span: Span, ty: P<ast::Ty>) -> ast::Stmt {
             init: None,
             id: ast::DUMMY_NODE_ID,
             span,
-            attrs: ThinVec::new(),
+            attrs: AttrVec::new(),
         });
         ast::Stmt {
             id: ast::DUMMY_NODE_ID,
@@ -245,7 +244,7 @@ pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P<ast::Expr> {
             id: ast::DUMMY_NODE_ID,
             kind,
             span,
-            attrs: ThinVec::new(),
+            attrs: AttrVec::new(),
         })
     }
 
@@ -304,7 +303,7 @@ pub fn field_imm(&self, span: Span, ident: Ident, e: P<ast::Expr>) -> ast::Field
             expr: e,
             span,
             is_shorthand: false,
-            attrs: ThinVec::new(),
+            attrs: AttrVec::new(),
             id: ast::DUMMY_NODE_ID,
             is_placeholder: false,
         }
@@ -549,7 +548,7 @@ pub fn lambda_stmts_1(&self, span: Span, stmts: Vec<ast::Stmt>,
     pub fn param(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Param {
         let arg_pat = self.pat_ident(span, ident);
         ast::Param {
-            attrs: ThinVec::default(),
+            attrs: AttrVec::default(),
             id: ast::DUMMY_NODE_ID,
             pat: arg_pat,
             span,
index 22e99baae5be0e9289e260cdaabd9fef7ae3adfd..4298e0e74b6e613f1b16a360fceb67c58556447c 100644 (file)
@@ -5,7 +5,6 @@
 use syntax::source_map::{DUMMY_SP, dummy_spanned};
 use syntax::mut_visit::*;
 use syntax::ptr::P;
-use syntax::ThinVec;
 
 use smallvec::{smallvec, SmallVec};
 
@@ -28,7 +27,7 @@ fn mac_placeholder() -> ast::Mac {
     let span = DUMMY_SP;
     let expr_placeholder = || P(ast::Expr {
         id, span,
-        attrs: ThinVec::new(),
+        attrs: ast::AttrVec::new(),
         kind: ast::ExprKind::Mac(mac_placeholder()),
     });
     let ty = || P(ast::Ty {
@@ -75,7 +74,7 @@ fn mac_placeholder() -> ast::Mac {
             id, span, kind: ast::TyKind::Mac(mac_placeholder()),
         })),
         AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
-            let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ThinVec::new()));
+            let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ast::AttrVec::new()));
             ast::Stmt { id, span, kind: ast::StmtKind::Mac(mac) }
         }]),
         AstFragmentKind::Arms => AstFragment::Arms(smallvec![
index bd345a9a7dada11c83573e30517fcf0d5e3a412e..5ec24b7a7acc5156ed968e2921f4ef747fccd559 100644 (file)
@@ -3,7 +3,6 @@
 use State::*;
 
 use errors::{DiagnosticBuilder, PResult};
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_parse::parser::Parser;
 use syntax_expand::base::*;
 use syntax_pos::Span;
@@ -63,7 +62,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
         id: ast::DUMMY_NODE_ID,
         kind: ast::ExprKind::InlineAsm(P(inline_asm)),
         span: cx.with_def_site_ctxt(sp),
-        attrs: ThinVec::new(),
+        attrs: ast::AttrVec::new(),
     }))
 }
 
index 8a1bc56cf1ced956340405f4440afcadd8d1ddba..7d8bc8b87bc2b83b3b802f4c6ea6f1a9c76fa1c1 100644 (file)
@@ -1,5 +1,3 @@
-use rustc_data_structures::thin_vec::ThinVec;
-
 use syntax::ast;
 use syntax_expand::base::{self, *};
 use syntax::token::{self, Token};
@@ -49,7 +47,7 @@ fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
                 id: ast::DUMMY_NODE_ID,
                 kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)),
                 span: self.ident.span,
-                attrs: ThinVec::new(),
+                attrs: ast::AttrVec::new(),
             }))
         }
 
index 35298211e4d31ce456941654415d49a63a225085..132ce76e1bb6dbcaa868e890e0680deac11d60d8 100644 (file)
@@ -2,8 +2,6 @@
 use crate::deriving::generic::*;
 use crate::deriving::generic::ty::*;
 
-use rustc_data_structures::thin_vec::ThinVec;
-
 use syntax::ast::{self, Ident};
 use syntax::ast::{Expr, MetaItem};
 use syntax_expand::base::{Annotatable, ExtCtxt};
@@ -127,7 +125,7 @@ fn stmt_let_undescore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P<ast::Expr>) -> ast
         init: Some(expr),
         id: ast::DUMMY_NODE_ID,
         span: sp,
-        attrs: ThinVec::new(),
+        attrs: ast::AttrVec::new(),
     });
     ast::Stmt {
         id: ast::DUMMY_NODE_ID,
index b7707bfb8e5fbd95f6f536ecf56811e54c708ac3..5158a5b3da217791af03505860f0591968b09130 100644 (file)
 use std::iter;
 use std::vec;
 
-use rustc_data_structures::thin_vec::ThinVec;
 use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
 use syntax::ast::{VariantData, GenericParamKind, GenericArg};
 use syntax::attr;
@@ -919,7 +918,7 @@ fn create_method(&self,
         let args = {
             let self_args = explicit_self.map(|explicit_self| {
                 let ident = Ident::with_dummy_span(kw::SelfLower).with_span_pos(trait_.span);
-                ast::Param::from_self(ThinVec::default(), explicit_self, ident)
+                ast::Param::from_self(ast::AttrVec::default(), explicit_self, ident)
             });
             let nonself_args = arg_types.into_iter()
                 .map(|(name, ty)| cx.param(trait_.span, name, ty));
@@ -1608,7 +1607,7 @@ fn create_struct_pattern
                         ast::FieldPat {
                             ident: ident.unwrap(),
                             is_shorthand: false,
-                            attrs: ThinVec::new(),
+                            attrs: ast::AttrVec::new(),
                             id: ast::DUMMY_NODE_ID,
                             span: pat.span.with_ctxt(self.span.ctxt()),
                             pat,