Skip to content

Commit bd0be08

Browse files
committed
Use ThinVec in ast::Impl and related types.
1 parent 64764e1 commit bd0be08

File tree

3 files changed

+8
-7
lines changed
  • compiler

3 files changed

+8
-7
lines changed

compiler/rustc_ast/src/ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ pub struct ForeignMod {
24352435
/// semantically by Rust.
24362436
pub unsafety: Unsafe,
24372437
pub abi: Option<StrLit>,
2438-
pub items: Vec<P<ForeignItem>>,
2438+
pub items: ThinVec<P<ForeignItem>>,
24392439
}
24402440

24412441
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -2753,7 +2753,7 @@ pub struct Trait {
27532753
pub is_auto: IsAuto,
27542754
pub generics: Generics,
27552755
pub bounds: GenericBounds,
2756-
pub items: Vec<P<AssocItem>>,
2756+
pub items: ThinVec<P<AssocItem>>,
27572757
}
27582758

27592759
/// The location of a where clause on a `TyAlias` (`Span`) and whether there was
@@ -2801,7 +2801,7 @@ pub struct Impl {
28012801
/// The trait being implemented, if any.
28022802
pub of_trait: Option<TraitRef>,
28032803
pub self_ty: P<Ty>,
2804-
pub items: Vec<P<AssocItem>>,
2804+
pub items: ThinVec<P<AssocItem>>,
28052805
}
28062806

28072807
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -3047,7 +3047,7 @@ mod size_asserts {
30473047
static_assert_size!(ForeignItemKind, 24);
30483048
static_assert_size!(GenericBound, 56);
30493049
static_assert_size!(Generics, 40);
3050-
static_assert_size!(Impl, 152);
3050+
static_assert_size!(Impl, 136);
30513051
static_assert_size!(Item, 152);
30523052
static_assert_size!(ItemKind, 80);
30533053
static_assert_size!(Lit, 48);

compiler/rustc_builtin_macros/src/deriving/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_ast::{GenericArg, Impl, ItemKind, MetaItem};
66
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier};
77
use rustc_span::symbol::{sym, Ident, Symbol};
88
use rustc_span::Span;
9+
use thin_vec::ThinVec;
910

1011
macro path_local($x:ident) {
1112
generic::ty::Path::new_local(sym::$x)
@@ -187,7 +188,7 @@ fn inject_impl_of_structural_trait(
187188
generics,
188189
of_trait: Some(trait_ref),
189190
self_ty: self_type,
190-
items: Vec::new(),
191+
items: ThinVec::new(),
191192
})),
192193
);
193194

compiler/rustc_parse/src/parser/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,12 @@ impl<'a> Parser<'a> {
663663
&mut self,
664664
attrs: &mut AttrVec,
665665
mut parse_item: impl FnMut(&mut Parser<'a>) -> PResult<'a, Option<Option<T>>>,
666-
) -> PResult<'a, Vec<T>> {
666+
) -> PResult<'a, ThinVec<T>> {
667667
let open_brace_span = self.token.span;
668668
self.expect(&token::OpenDelim(Delimiter::Brace))?;
669669
attrs.extend(self.parse_inner_attributes()?);
670670

671-
let mut items = Vec::new();
671+
let mut items = ThinVec::new();
672672
while !self.eat(&token::CloseDelim(Delimiter::Brace)) {
673673
if self.recover_doc_comment_before_brace() {
674674
continue;

0 commit comments

Comments
 (0)