Skip to content

Commit 6a56c3a

Browse files
committed
Use ThinVec in ast::Impl and related types.
1 parent 068db46 commit 6a56c3a

File tree

3 files changed

+9
-8
lines changed
  • compiler

3 files changed

+9
-8
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,7 @@ pub struct ForeignMod {
24972497
/// semantically by Rust.
24982498
pub unsafety: Unsafe,
24992499
pub abi: Option<StrLit>,
2500-
pub items: Vec<P<ForeignItem>>,
2500+
pub items: ThinVec<P<ForeignItem>>,
25012501
}
25022502

25032503
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -2826,7 +2826,7 @@ pub struct Trait {
28262826
pub is_auto: IsAuto,
28272827
pub generics: Generics,
28282828
pub bounds: GenericBounds,
2829-
pub items: Vec<P<AssocItem>>,
2829+
pub items: ThinVec<P<AssocItem>>,
28302830
}
28312831

28322832
/// The location of a where clause on a `TyAlias` (`Span`) and whether there was
@@ -2874,7 +2874,7 @@ pub struct Impl {
28742874
/// The trait being implemented, if any.
28752875
pub of_trait: Option<TraitRef>,
28762876
pub self_ty: P<Ty>,
2877-
pub items: Vec<P<AssocItem>>,
2877+
pub items: ThinVec<P<AssocItem>>,
28782878
}
28792879

28802880
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -3121,7 +3121,7 @@ mod size_asserts {
31213121
static_assert_size!(GenericArg, 24);
31223122
static_assert_size!(GenericBound, 56);
31233123
static_assert_size!(Generics, 40);
3124-
static_assert_size!(Impl, 152);
3124+
static_assert_size!(Impl, 136);
31253125
static_assert_size!(Item, 152);
31263126
static_assert_size!(ItemKind, 80);
31273127
static_assert_size!(LitKind, 24);

compiler/rustc_builtin_macros/src/deriving/mod.rs

Lines changed: 2 additions & 1 deletion
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)
@@ -202,7 +203,7 @@ fn inject_impl_of_structural_trait(
202203
generics,
203204
of_trait: Some(trait_ref),
204205
self_ty: self_type,
205-
items: Vec::new(),
206+
items: ThinVec::new(),
206207
})),
207208
);
208209

compiler/rustc_parse/src/parser/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,20 +646,20 @@ impl<'a> Parser<'a> {
646646
&mut self,
647647
attrs: &mut AttrVec,
648648
mut parse_item: impl FnMut(&mut Parser<'a>) -> PResult<'a, Option<Option<T>>>,
649-
) -> PResult<'a, Vec<T>> {
649+
) -> PResult<'a, ThinVec<T>> {
650650
let open_brace_span = self.token.span;
651651

652652
// Recover `impl Ty;` instead of `impl Ty {}`
653653
if self.token == TokenKind::Semi {
654654
self.sess.emit_err(errors::UseEmptyBlockNotSemi { span: self.token.span });
655655
self.bump();
656-
return Ok(vec![]);
656+
return Ok(ThinVec::new());
657657
}
658658

659659
self.expect(&token::OpenDelim(Delimiter::Brace))?;
660660
attrs.extend(self.parse_inner_attributes()?);
661661

662-
let mut items = Vec::new();
662+
let mut items = ThinVec::new();
663663
while !self.eat(&token::CloseDelim(Delimiter::Brace)) {
664664
if self.recover_doc_comment_before_brace() {
665665
continue;

0 commit comments

Comments
 (0)