Skip to content

Commit

Permalink
Use ThinVec in ast::Impl and related types.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Sep 7, 2022
1 parent 6d0b6fa commit 7b7fee4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ pub struct ForeignMod {
/// semantically by Rust.
pub unsafety: Unsafe,
pub abi: Option<StrLit>,
pub items: Vec<P<ForeignItem>>,
pub items: ThinVec<P<ForeignItem>>,
}

#[derive(Clone, Encodable, Decodable, Debug)]
Expand Down Expand Up @@ -2786,7 +2786,7 @@ pub struct Trait {
pub is_auto: IsAuto,
pub generics: Generics,
pub bounds: GenericBounds,
pub items: Vec<P<AssocItem>>,
pub items: ThinVec<P<AssocItem>>,
}

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

#[derive(Clone, Encodable, Decodable, Debug)]
Expand Down Expand Up @@ -3081,7 +3081,7 @@ mod size_asserts {
static_assert_size!(GenericArg, 24);
static_assert_size!(GenericBound, 56);
static_assert_size!(Generics, 40);
static_assert_size!(Impl, 152);
static_assert_size!(Impl, 136);
static_assert_size!(Item, 152);
static_assert_size!(ItemKind, 80);
static_assert_size!(Lit, 48);
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rustc_ast::{GenericArg, Impl, ItemKind, MetaItem};
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::ThinVec;

macro path_local($x:ident) {
generic::ty::Path::new_local(sym::$x)
Expand Down Expand Up @@ -187,7 +188,7 @@ fn inject_impl_of_structural_trait(
generics,
of_trait: Some(trait_ref),
self_ty: self_type,
items: Vec::new(),
items: ThinVec::new(),
})),
);

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,12 @@ impl<'a> Parser<'a> {
&mut self,
attrs: &mut AttrVec,
mut parse_item: impl FnMut(&mut Parser<'a>) -> PResult<'a, Option<Option<T>>>,
) -> PResult<'a, Vec<T>> {
) -> PResult<'a, ThinVec<T>> {
let open_brace_span = self.token.span;
self.expect(&token::OpenDelim(Delimiter::Brace))?;
attrs.extend(self.parse_inner_attributes()?);

let mut items = Vec::new();
let mut items = ThinVec::new();
while !self.eat(&token::CloseDelim(Delimiter::Brace)) {
if self.recover_doc_comment_before_brace() {
continue;
Expand Down

0 comments on commit 7b7fee4

Please sign in to comment.