From: Mazdak Farrokhzad Date: Tue, 3 Dec 2019 15:38:34 +0000 (+0100) Subject: introduce 'type AttrVec' X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=a0d20935cc7dc9057c683bb62a4ba74475f32aa2;p=rust.git introduce 'type AttrVec' --- diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 3f8085f2344..6b83788298e 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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 { /// 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 { @@ -3102,7 +3101,7 @@ fn stmt_expr(&mut self, span: Span, expr: hir::Expr) -> hir::Stmt { fn stmt_let_pat( &mut self, - attrs: ThinVec, + attrs: AttrVec, span: Span, init: Option>, pat: P, diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index f8465baeb13..04031710dc5 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -1318,8 +1318,7 @@ pub(super) fn expr_drop_temps( &mut self, span: Span, expr: P, - attrs: ThinVec - ) -> 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) -> P { + fn expr_break(&mut self, span: Span, attrs: AttrVec) -> P { 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>, - attrs: ThinVec, + 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, + 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, attrs: ThinVec) -> hir::Expr { + pub(super) fn expr_block(&mut self, b: P, 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 - ) -> 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 } } diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 46c944fa678..6cae8e2cc04 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -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())) }) } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 6b354b01518..17f4ec34441 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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>, pub hir_id: HirId, pub span: Span, - pub attrs: ThinVec, + 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, + pub attrs: AttrVec, pub span: Span, } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 4d686fc310f..a8800082c9a 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -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 { diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index cea17e4d006..16daefd1450 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -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, 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, + attrs: AttrVec, ) -> PResult<'a, P> { let (hi, expr, is_question) = if self.token == token::Not { // Handle `await!()`. @@ -1005,7 +1004,7 @@ fn recover_await_prefix(&mut self, await_sp: Span) -> PResult<'a, (Span, P 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()) } } } diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 4edfbc4ec9f..7afa3d665d6 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -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), + AttributesParsed(AttrVec), AlreadyParsed(P), } -impl From>> for LhsExpr { +impl From> for LhsExpr { /// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)` /// and `None` into `LhsExpr::NotYetParsed`. /// /// This conversion does not allocate. - fn from(o: Option>) -> Self { + fn from(o: Option) -> Self { if let Some(attrs) = o { LhsExpr::AttributesParsed(attrs) } else { @@ -103,7 +102,7 @@ fn parse_expr_catch_underscore(&mut self) -> PResult<'a, P> { 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>> { pub(super) fn parse_expr_res( &mut self, r: Restrictions, - already_parsed_attrs: Option> + already_parsed_attrs: Option ) -> PResult<'a, P> { 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>, + already_parsed_attrs: Option, ) -> PResult<'a, P> { 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> + already_parsed_attrs: Option ) -> PResult<'a, P> { // 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> - ) -> PResult<'a, P> { + fn parse_prefix_expr(&mut self, already_parsed_attrs: Option) -> PResult<'a, P> { 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, lhs_span: Span, expr_kind: fn(P, P) -> ExprKind) -> PResult<'a, P> { let mk_expr = |this: &mut Self, rhs: P| { - 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>, + already_parsed_attrs: Option, ) -> PResult<'a, P> { 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, lo: Span, - mut attrs: ThinVec, + mut attrs: AttrVec, ) -> PResult<'a, P> { // 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, 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, 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, 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, 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, lo: Span) -> PResult<'a, P { // Field access `expr.f` @@ -801,7 +797,7 @@ fn parse_dot_suffix(&mut self, self_arg: P, lo: Span) -> PResult<'a, P PResult<'a, P> { // // 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> { } } - fn parse_lit_expr(&mut self, attrs: ThinVec) -> PResult<'a, P> { + fn parse_lit_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { let lo = self.token.span; match self.parse_opt_lit() { Some(literal) => { @@ -920,7 +916,7 @@ fn parse_lit_expr(&mut self, attrs: ThinVec) -> PResult<'a, P> } } - fn parse_tuple_parens_expr(&mut self, mut attrs: ThinVec) -> PResult<'a, P> { + fn parse_tuple_parens_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P> { 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) -> PResult< self.maybe_recover_from_bad_qpath(expr, true) } - fn parse_array_or_repeat_expr( - &mut self, - mut attrs: ThinVec, - ) -> PResult<'a, P> { + fn parse_array_or_repeat_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P> { 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) -> PResult<'a, P> { + fn parse_path_start_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { 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) -> PResult<'a, P< self.maybe_recover_from_bad_qpath(expr, true) } - fn parse_labeled_expr( - &mut self, - label: Label, - attrs: ThinVec, - ) -> PResult<'a, P> { + fn parse_labeled_expr(&mut self, label: Label, attrs: AttrVec) -> PResult<'a, P> { 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) -> PResult<'a, P> { + fn recover_do_catch(&mut self, attrs: AttrVec) -> PResult<'a, P> { let lo = self.token.span; self.bump(); // `do` @@ -1076,7 +1065,7 @@ fn parse_expr_opt(&mut self) -> PResult<'a, Option>> { } /// Parse `"return" expr?`. - fn parse_return_expr(&mut self, attrs: ThinVec) -> PResult<'a, P> { + fn parse_return_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { 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) -> PResult<'a, P) -> PResult<'a, P> { + fn parse_break_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { 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) -> PResult<'a, P } /// Parse `"yield" expr?`. - fn parse_yield_expr(&mut self, attrs: ThinVec) -> PResult<'a, P> { + fn parse_yield_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { 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> { 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