Skip to content

Commit 1807027

Browse files
committed
Use ThinVec in ast::AngleBracketedArgs.
1 parent b14b7ba commit 1807027

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

compiler/rustc_ast/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub struct AngleBracketedArgs {
209209
/// The overall span.
210210
pub span: Span,
211211
/// The comma separated parts in the `<...>`.
212-
pub args: Vec<AngleBracketedArg>,
212+
pub args: ThinVec<AngleBracketedArg>,
213213
}
214214

215215
/// Either an argument for a parameter e.g., `'a`, `Vec<u8>`, `0`,

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ pub fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>(
577577
vis: &mut T,
578578
) {
579579
let AngleBracketedArgs { args, span } = data;
580-
visit_vec(args, |arg| match arg {
580+
visit_thin_vec(args, |arg| match arg {
581581
AngleBracketedArg::Arg(arg) => vis.visit_generic_arg(arg),
582582
AngleBracketedArg::Constraint(constraint) => vis.visit_constraint(constraint),
583583
});

compiler/rustc_ast_lowering/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
376376

377377
// Split the arguments into const generics and normal arguments
378378
let mut real_args = vec![];
379-
let mut generic_args = vec![];
379+
let mut generic_args = ThinVec::new();
380380
for (idx, arg) in args.into_iter().enumerate() {
381381
if legacy_args_idx.contains(&idx) {
382382
let parent_def_id = self.current_hir_id_owner;

compiler/rustc_ast_passes/src/ast_validation.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rustc_span::Span;
2727
use rustc_target::spec::abi;
2828
use std::mem;
2929
use std::ops::{Deref, DerefMut};
30+
use thin_vec::thin_vec;
3031

3132
use crate::errors::*;
3233

@@ -1615,7 +1616,7 @@ fn deny_equality_constraints(
16151616
empty_args => {
16161617
*empty_args = AngleBracketedArgs {
16171618
span: ident.span,
1618-
args: vec![arg],
1619+
args: thin_vec![arg],
16191620
}
16201621
.into();
16211622
}

compiler/rustc_parse/src/parser/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,7 @@ impl<'a> Parser<'a> {
21992199
/// like the user has forgotten them.
22002200
pub fn handle_ambiguous_unbraced_const_arg(
22012201
&mut self,
2202-
args: &mut Vec<AngleBracketedArg>,
2202+
args: &mut ThinVec<AngleBracketedArg>,
22032203
) -> PResult<'a, bool> {
22042204
// If we haven't encountered a closing `>`, then the argument is malformed.
22052205
// It's likely that the user has written a const expression without enclosing it

compiler/rustc_parse/src/parser/path.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'a> Parser<'a> {
332332
style: PathStyle,
333333
lo: Span,
334334
ty_generics: Option<&Generics>,
335-
) -> PResult<'a, Vec<AngleBracketedArg>> {
335+
) -> PResult<'a, ThinVec<AngleBracketedArg>> {
336336
// We need to detect whether there are extra leading left angle brackets and produce an
337337
// appropriate error and suggestion. This cannot be implemented by looking ahead at
338338
// upcoming tokens for a matching `>` character - if there are unmatched `<` tokens
@@ -472,8 +472,8 @@ impl<'a> Parser<'a> {
472472
pub(super) fn parse_angle_args(
473473
&mut self,
474474
ty_generics: Option<&Generics>,
475-
) -> PResult<'a, Vec<AngleBracketedArg>> {
476-
let mut args = Vec::new();
475+
) -> PResult<'a, ThinVec<AngleBracketedArg>> {
476+
let mut args = ThinVec::new();
477477
while let Some(arg) = self.parse_angle_arg(ty_generics)? {
478478
args.push(arg);
479479
if !self.eat(&token::Comma) {

0 commit comments

Comments
 (0)