Skip to content

Commit 7b7fee4

Browse files
committed
Use ThinVec in ast::Impl and related types.
1 parent 6d0b6fa commit 7b7fee4

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
@@ -2468,7 +2468,7 @@ pub struct ForeignMod {
24682468
/// semantically by Rust.
24692469
pub unsafety: Unsafe,
24702470
pub abi: Option<StrLit>,
2471-
pub items: Vec<P<ForeignItem>>,
2471+
pub items: ThinVec<P<ForeignItem>>,
24722472
}
24732473

24742474
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -2786,7 +2786,7 @@ pub struct Trait {
27862786
pub is_auto: IsAuto,
27872787
pub generics: Generics,
27882788
pub bounds: GenericBounds,
2789-
pub items: Vec<P<AssocItem>>,
2789+
pub items: ThinVec<P<AssocItem>>,
27902790
}
27912791

27922792
/// The location of a where clause on a `TyAlias` (`Span`) and whether there was
@@ -2834,7 +2834,7 @@ pub struct Impl {
28342834
/// The trait being implemented, if any.
28352835
pub of_trait: Option<TraitRef>,
28362836
pub self_ty: P<Ty>,
2837-
pub items: Vec<P<AssocItem>>,
2837+
pub items: ThinVec<P<AssocItem>>,
28382838
}
28392839

28402840
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -3081,7 +3081,7 @@ mod size_asserts {
30813081
static_assert_size!(GenericArg, 24);
30823082
static_assert_size!(GenericBound, 56);
30833083
static_assert_size!(Generics, 40);
3084-
static_assert_size!(Impl, 152);
3084+
static_assert_size!(Impl, 136);
30853085
static_assert_size!(Item, 152);
30863086
static_assert_size!(ItemKind, 80);
30873087
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
@@ -662,12 +662,12 @@ impl<'a> Parser<'a> {
662662
&mut self,
663663
attrs: &mut AttrVec,
664664
mut parse_item: impl FnMut(&mut Parser<'a>) -> PResult<'a, Option<Option<T>>>,
665-
) -> PResult<'a, Vec<T>> {
665+
) -> PResult<'a, ThinVec<T>> {
666666
let open_brace_span = self.token.span;
667667
self.expect(&token::OpenDelim(Delimiter::Brace))?;
668668
attrs.extend(self.parse_inner_attributes()?);
669669

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

0 commit comments

Comments
 (0)