diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-11-22 16:32:08 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-02-21 11:51:55 +1100 |
| commit | 6a56c3a930733b7e000cc3ec54844b0522a8bd16 (patch) | |
| tree | 304d1074fee6eed86861f93b7e1e56d76dbadd4f | |
| parent | 068db466e889d73c65007dc04a05a760e3d9f766 (diff) | |
| download | rust-6a56c3a930733b7e000cc3ec54844b0522a8bd16.tar.gz rust-6a56c3a930733b7e000cc3ec54844b0522a8bd16.zip | |
Use `ThinVec` in `ast::Impl` and related types.
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_builtin_macros/src/deriving/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 6 |
3 files changed, 9 insertions, 8 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 9ed451f13b2..42105b67e94 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2497,7 +2497,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)] @@ -2826,7 +2826,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 @@ -2874,7 +2874,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)] @@ -3121,7 +3121,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!(LitKind, 24); diff --git a/compiler/rustc_builtin_macros/src/deriving/mod.rs b/compiler/rustc_builtin_macros/src/deriving/mod.rs index de657e4e600..1ecaca370db 100644 --- a/compiler/rustc_builtin_macros/src/deriving/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/mod.rs @@ -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) @@ -202,7 +203,7 @@ fn inject_impl_of_structural_trait( generics, of_trait: Some(trait_ref), self_ty: self_type, - items: Vec::new(), + items: ThinVec::new(), })), ); diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index f164bb330f3..43e449a258f 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -646,20 +646,20 @@ 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; // Recover `impl Ty;` instead of `impl Ty {}` if self.token == TokenKind::Semi { self.sess.emit_err(errors::UseEmptyBlockNotSemi { span: self.token.span }); self.bump(); - return Ok(vec![]); + return Ok(ThinVec::new()); } 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; |
