Use ThinVec in ast::Generics and related types.

This commit is contained in:
Nicholas Nethercote
2022-11-22 09:17:20 +11:00
parent 06228d6e93
commit dd7aff5cc5
12 changed files with 97 additions and 97 deletions

View File

@@ -14,6 +14,7 @@ use rustc_ast::{
use rustc_errors::{Applicability, PResult};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use thin_vec::ThinVec;
enum PredicateOrStructBody {
Predicate(ast::WherePredicate),
@@ -121,8 +122,8 @@ impl<'a> Parser<'a> {
/// Parses a (possibly empty) list of lifetime and type parameters, possibly including
/// a trailing comma and erroneous trailing attributes.
pub(super) fn parse_generic_params(&mut self) -> PResult<'a, Vec<ast::GenericParam>> {
let mut params = Vec::new();
pub(super) fn parse_generic_params(&mut self) -> PResult<'a, ThinVec<ast::GenericParam>> {
let mut params = ThinVec::new();
let mut done = false;
while !done {
let attrs = self.parse_outer_attributes()?;
@@ -251,7 +252,7 @@ impl<'a> Parser<'a> {
self.expect_gt()?;
(params, span_lo.to(self.prev_token.span))
} else {
(vec![], self.prev_token.span.shrink_to_hi())
(ThinVec::new(), self.prev_token.span.shrink_to_hi())
};
Ok(ast::Generics {
params,