Skip to content

Commit a0d2093

Browse files
committed
introduce 'type AttrVec'
1 parent 3d5dbcb commit a0d2093

File tree

23 files changed

+136
-176
lines changed

23 files changed

+136
-176
lines changed

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ use crate::util::nodemap::{DefIdMap, NodeMap};
5353
use errors::Applicability;
5454
use rustc_data_structures::fx::FxHashSet;
5555
use rustc_index::vec::IndexVec;
56-
use rustc_data_structures::thin_vec::ThinVec;
5756
use rustc_data_structures::sync::Lrc;
5857

5958
use std::collections::BTreeMap;
@@ -1205,7 +1204,7 @@ impl<'a> LoweringContext<'a> {
12051204
id: ty.id,
12061205
kind: ExprKind::Path(qself.clone(), path.clone()),
12071206
span: ty.span,
1208-
attrs: ThinVec::new(),
1207+
attrs: AttrVec::new(),
12091208
};
12101209

12111210
let ct = self.with_new_scopes(|this| {
@@ -2751,7 +2750,7 @@ impl<'a> LoweringContext<'a> {
27512750
/// has no attributes and is not targeted by a `break`.
27522751
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr {
27532752
let block = self.lower_block(b, false);
2754-
self.expr_block(block, ThinVec::new())
2753+
self.expr_block(block, AttrVec::new())
27552754
}
27562755

27572756
fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
@@ -3102,7 +3101,7 @@ impl<'a> LoweringContext<'a> {
31023101

31033102
fn stmt_let_pat(
31043103
&mut self,
3105-
attrs: ThinVec<Attribute>,
3104+
attrs: AttrVec,
31063105
span: Span,
31073106
init: Option<P<hir::Expr>>,
31083107
pat: P<hir::Pat>,

src/librustc/hir/lowering/expr.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,7 @@ impl LoweringContext<'_> {
13181318
&mut self,
13191319
span: Span,
13201320
expr: P<hir::Expr>,
1321-
attrs: ThinVec<Attribute>
1322-
) -> hir::Expr {
1321+
attrs: AttrVec) -> hir::Expr {
13231322
self.expr(span, hir::ExprKind::DropTemps(expr), attrs)
13241323
}
13251324

@@ -1333,7 +1332,7 @@ impl LoweringContext<'_> {
13331332
self.expr(span, hir::ExprKind::Match(arg, arms, source), ThinVec::new())
13341333
}
13351334

1336-
fn expr_break(&mut self, span: Span, attrs: ThinVec<Attribute>) -> P<hir::Expr> {
1335+
fn expr_break(&mut self, span: Span, attrs: AttrVec) -> P<hir::Expr> {
13371336
let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None);
13381337
P(self.expr(span, expr_break, attrs))
13391338
}
@@ -1404,7 +1403,7 @@ impl LoweringContext<'_> {
14041403
span: Span,
14051404
components: &[Symbol],
14061405
params: Option<P<hir::GenericArgs>>,
1407-
attrs: ThinVec<Attribute>,
1406+
attrs: AttrVec,
14081407
) -> hir::Expr {
14091408
let path = self.std_path(span, components, params, true);
14101409
self.expr(
@@ -1423,7 +1422,7 @@ impl LoweringContext<'_> {
14231422
span: Span,
14241423
ident: Ident,
14251424
binding: hir::HirId,
1426-
attrs: ThinVec<Attribute>,
1425+
attrs: AttrVec,
14271426
) -> hir::Expr {
14281427
let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
14291428
None,
@@ -1459,16 +1458,11 @@ impl LoweringContext<'_> {
14591458
self.expr_block(P(blk), ThinVec::new())
14601459
}
14611460

1462-
pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: ThinVec<Attribute>) -> hir::Expr {
1461+
pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: AttrVec) -> hir::Expr {
14631462
self.expr(b.span, hir::ExprKind::Block(b, None), attrs)
14641463
}
14651464

1466-
pub(super) fn expr(
1467-
&mut self,
1468-
span: Span,
1469-
kind: hir::ExprKind,
1470-
attrs: ThinVec<Attribute>
1471-
) -> hir::Expr {
1465+
pub(super) fn expr(&mut self, span: Span, kind: hir::ExprKind, attrs: AttrVec) -> hir::Expr {
14721466
hir::Expr { hir_id: self.next_id(), kind, span, attrs }
14731467
}
14741468

src/librustc/hir/lowering/item.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::hir::def_id::DefId;
1111
use crate::hir::def::{Res, DefKind};
1212
use crate::util::nodemap::NodeMap;
1313

14-
use rustc_data_structures::thin_vec::ThinVec;
1514
use rustc_target::spec::abi;
1615

1716
use std::collections::BTreeSet;
@@ -899,7 +898,7 @@ impl LoweringContext<'_> {
899898

900899
/// Construct `ExprKind::Err` for the given `span`.
901900
fn expr_err(&mut self, span: Span) -> hir::Expr {
902-
self.expr(span, hir::ExprKind::Err, ThinVec::new())
901+
self.expr(span, hir::ExprKind::Err, AttrVec::new())
903902
}
904903

905904
fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem {
@@ -1182,7 +1181,7 @@ impl LoweringContext<'_> {
11821181
//
11831182
// If this is the simple case, this parameter will end up being the same as the
11841183
// original parameter, but with a different pattern id.
1185-
let mut stmt_attrs = ThinVec::new();
1184+
let mut stmt_attrs = AttrVec::new();
11861185
stmt_attrs.extend(parameter.attrs.iter().cloned());
11871186
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
11881187
let new_parameter = hir::Param {
@@ -1226,7 +1225,7 @@ impl LoweringContext<'_> {
12261225
desugared_span, ident, hir::BindingAnnotation::Mutable);
12271226
let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
12281227
let move_stmt = this.stmt_let_pat(
1229-
ThinVec::new(),
1228+
AttrVec::new(),
12301229
desugared_span,
12311230
Some(P(move_expr)),
12321231
move_pat,
@@ -1271,7 +1270,7 @@ impl LoweringContext<'_> {
12711270
let user_body = this.expr_drop_temps(
12721271
desugared_span,
12731272
P(user_body),
1274-
ThinVec::new(),
1273+
AttrVec::new(),
12751274
);
12761275

12771276
// As noted above, create the final block like
@@ -1288,9 +1287,9 @@ impl LoweringContext<'_> {
12881287
statements.into(),
12891288
Some(P(user_body)),
12901289
);
1291-
this.expr_block(P(body), ThinVec::new())
1290+
this.expr_block(P(body), AttrVec::new())
12921291
});
1293-
(HirVec::from(parameters), this.expr(body_span, async_expr, ThinVec::new()))
1292+
(HirVec::from(parameters), this.expr(body_span, async_expr, AttrVec::new()))
12941293
})
12951294
}
12961295

src/librustc/hir/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use errors::FatalError;
2020
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
2121
use syntax::source_map::Spanned;
2222
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
23-
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
23+
use syntax::ast::{AttrVec, Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
2424
pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy};
2525
pub use syntax::ast::{IsAuto, ImplPolarity, BorrowKind};
2626
use syntax::attr::{InlineAttr, OptimizeAttr};
@@ -29,7 +29,6 @@ use syntax::tokenstream::TokenStream;
2929
use syntax::util::parser::ExprPrecedence;
3030
use rustc_target::spec::abi::Abi;
3131
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
32-
use rustc_data_structures::thin_vec::ThinVec;
3332
use rustc_macros::HashStable;
3433
use rustc_serialize::{self, Encoder, Encodable, Decoder, Decodable};
3534
use std::collections::{BTreeSet, BTreeMap};
@@ -1274,7 +1273,7 @@ pub struct Local {
12741273
pub init: Option<P<Expr>>,
12751274
pub hir_id: HirId,
12761275
pub span: Span,
1277-
pub attrs: ThinVec<Attribute>,
1276+
pub attrs: AttrVec,
12781277
/// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
12791278
/// desugaring. Otherwise will be `Normal`.
12801279
pub source: LocalSource,
@@ -1459,7 +1458,7 @@ pub struct AnonConst {
14591458
pub struct Expr {
14601459
pub hir_id: HirId,
14611460
pub kind: ExprKind,
1462-
pub attrs: ThinVec<Attribute>,
1461+
pub attrs: AttrVec,
14631462
pub span: Span,
14641463
}
14651464

src/librustc_interface/util.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_data_structures::jobserver;
1010
use rustc_data_structures::sync::{Lock, Lrc};
1111
use rustc_data_structures::stable_hasher::StableHasher;
1212
use rustc_data_structures::fingerprint::Fingerprint;
13-
use rustc_data_structures::thin_vec::ThinVec;
1413
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
1514
use rustc_errors::registry::Registry;
1615
use rustc_metadata::dynamic_lib::DynamicLibrary;
@@ -24,7 +23,7 @@ use std::ops::DerefMut;
2423
use smallvec::SmallVec;
2524
use syntax::ptr::P;
2625
use syntax::mut_visit::{*, MutVisitor, visit_clobber};
27-
use syntax::ast::BlockCheckMode;
26+
use syntax::ast::{AttrVec, BlockCheckMode};
2827
use syntax::util::lev_distance::find_best_match_for_name;
2928
use syntax::source_map::{FileLoader, RealFileLoader, SourceMap};
3029
use syntax::symbol::{Symbol, sym};
@@ -741,7 +740,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
741740
id: resolver.next_node_id(),
742741
kind: ast::ExprKind::Block(P(b), None),
743742
span: syntax_pos::DUMMY_SP,
744-
attrs: ThinVec::new(),
743+
attrs: AttrVec::new(),
745744
});
746745

747746
ast::Stmt {
@@ -756,7 +755,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
756755
kind: ast::ExprKind::Loop(P(empty_block), None),
757756
id: self.resolver.next_node_id(),
758757
span: syntax_pos::DUMMY_SP,
759-
attrs: ThinVec::new(),
758+
attrs: AttrVec::new(),
760759
});
761760

762761
let loop_stmt = ast::Stmt {

src/librustc_parse/parser/diagnostics.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use rustc_data_structures::fx::FxHashSet;
44
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
55
use rustc_error_codes::*;
66
use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
7-
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind, Attribute};
7+
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind, AttrVec};
88
use syntax::token::{self, TokenKind, token_can_begin_expr};
99
use syntax::print::pprust;
1010
use syntax::ptr::P;
11-
use syntax::ThinVec;
1211
use syntax::util::parser::AssocOp;
1312
use syntax::struct_span_err;
1413
use syntax_pos::symbol::kw;
@@ -32,7 +31,7 @@ pub(super) fn dummy_arg(ident: Ident) -> Param {
3231
id: ast::DUMMY_NODE_ID
3332
};
3433
Param {
35-
attrs: ThinVec::default(),
34+
attrs: AttrVec::default(),
3635
id: ast::DUMMY_NODE_ID,
3736
pat,
3837
span: ident.span,
@@ -164,7 +163,7 @@ impl RecoverQPath for Expr {
164163
Self {
165164
span: path.span,
166165
kind: ExprKind::Path(qself, path),
167-
attrs: ThinVec::new(),
166+
attrs: AttrVec::new(),
168167
id: ast::DUMMY_NODE_ID,
169168
}
170169
}
@@ -551,7 +550,7 @@ impl<'a> Parser<'a> {
551550
);
552551

553552
let mk_err_expr = |this: &Self, span| {
554-
Ok(Some(this.mk_expr(span, ExprKind::Err, ThinVec::new())))
553+
Ok(Some(this.mk_expr(span, ExprKind::Err, AttrVec::new())))
555554
};
556555

557556
match lhs.kind {
@@ -974,7 +973,7 @@ impl<'a> Parser<'a> {
974973
&mut self,
975974
lo: Span,
976975
await_sp: Span,
977-
attrs: ThinVec<Attribute>,
976+
attrs: AttrVec,
978977
) -> PResult<'a, P<Expr>> {
979978
let (hi, expr, is_question) = if self.token == token::Not {
980979
// Handle `await!(<expr>)`.
@@ -1005,7 +1004,7 @@ impl<'a> Parser<'a> {
10051004
None,
10061005
self.token.span,
10071006
BlockCheckMode::Default,
1008-
ThinVec::new(),
1007+
AttrVec::new(),
10091008
)
10101009
} else {
10111010
self.parse_expr()
@@ -1126,7 +1125,7 @@ impl<'a> Parser<'a> {
11261125
err.emit();
11271126
// Recover from parse error, callers expect the closing delim to be consumed.
11281127
self.consume_block(delim, ConsumeClosingDelim::Yes);
1129-
self.mk_expr(lo.to(self.prev_span), ExprKind::Err, ThinVec::new())
1128+
self.mk_expr(lo.to(self.prev_span), ExprKind::Err, AttrVec::new())
11301129
}
11311130
}
11321131
}

0 commit comments

Comments
 (0)