mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Use ThinVec
in ast::Impl
and related types.
This commit is contained in:
parent
068db466e8
commit
6a56c3a930
@ -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);
|
||||
|
@ -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(),
|
||||
})),
|
||||
);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user