diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index e485bdc0972..79cb2c946c8 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -209,7 +209,7 @@ pub struct AngleBracketedArgs { /// The overall span. pub span: Span, /// The comma separated parts in the `<...>`. - pub args: Vec, + pub args: ThinVec, } /// Either an argument for a parameter e.g., `'a`, `Vec`, `0`, diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 6fac99e6d89..7dcb03b4c78 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -577,7 +577,7 @@ pub fn noop_visit_angle_bracketed_parameter_data( vis: &mut T, ) { let AngleBracketedArgs { args, span } = data; - visit_vec(args, |arg| match arg { + visit_thin_vec(args, |arg| match arg { AngleBracketedArg::Arg(arg) => vis.visit_generic_arg(arg), AngleBracketedArg::Constraint(constraint) => vis.visit_constraint(constraint), }); diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 511adbd5e63..dfe790b4851 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -376,7 +376,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // Split the arguments into const generics and normal arguments let mut real_args = vec![]; - let mut generic_args = vec![]; + let mut generic_args = ThinVec::new(); for (idx, arg) in args.into_iter().enumerate() { if legacy_args_idx.contains(&idx) { let parent_def_id = self.current_hir_id_owner; diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index d1ae8c1fdbd..afa29a510d2 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -27,6 +27,7 @@ use rustc_span::Span; use rustc_target::spec::abi; use std::mem; use std::ops::{Deref, DerefMut}; +use thin_vec::thin_vec; use crate::errors::*; @@ -1615,7 +1616,7 @@ fn deny_equality_constraints( empty_args => { *empty_args = AngleBracketedArgs { span: ident.span, - args: vec![arg], + args: thin_vec![arg], } .into(); } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index baa99c48c66..46685dcc45d 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2199,7 +2199,7 @@ impl<'a> Parser<'a> { /// like the user has forgotten them. pub fn handle_ambiguous_unbraced_const_arg( &mut self, - args: &mut Vec, + args: &mut ThinVec, ) -> PResult<'a, bool> { // If we haven't encountered a closing `>`, then the argument is malformed. // It's likely that the user has written a const expression without enclosing it diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 49959a8981c..99416c3b204 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -332,7 +332,7 @@ impl<'a> Parser<'a> { style: PathStyle, lo: Span, ty_generics: Option<&Generics>, - ) -> PResult<'a, Vec> { + ) -> PResult<'a, ThinVec> { // We need to detect whether there are extra leading left angle brackets and produce an // appropriate error and suggestion. This cannot be implemented by looking ahead at // upcoming tokens for a matching `>` character - if there are unmatched `<` tokens @@ -472,8 +472,8 @@ impl<'a> Parser<'a> { pub(super) fn parse_angle_args( &mut self, ty_generics: Option<&Generics>, - ) -> PResult<'a, Vec> { - let mut args = Vec::new(); + ) -> PResult<'a, ThinVec> { + let mut args = ThinVec::new(); while let Some(arg) = self.parse_angle_arg(ty_generics)? { args.push(arg); if !self.eat(&token::Comma) {