mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Use ThinVec
in ast::AngleBracketedArgs
.
This commit is contained in:
parent
b14b7ba5dd
commit
1807027248
@ -209,7 +209,7 @@ pub struct AngleBracketedArgs {
|
||||
/// The overall span.
|
||||
pub span: Span,
|
||||
/// The comma separated parts in the `<...>`.
|
||||
pub args: Vec<AngleBracketedArg>,
|
||||
pub args: ThinVec<AngleBracketedArg>,
|
||||
}
|
||||
|
||||
/// Either an argument for a parameter e.g., `'a`, `Vec<u8>`, `0`,
|
||||
|
@ -577,7 +577,7 @@ pub fn noop_visit_angle_bracketed_parameter_data<T: MutVisitor>(
|
||||
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),
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<AngleBracketedArg>,
|
||||
args: &mut ThinVec<AngleBracketedArg>,
|
||||
) -> 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
|
||||
|
@ -332,7 +332,7 @@ impl<'a> Parser<'a> {
|
||||
style: PathStyle,
|
||||
lo: Span,
|
||||
ty_generics: Option<&Generics>,
|
||||
) -> PResult<'a, Vec<AngleBracketedArg>> {
|
||||
) -> PResult<'a, ThinVec<AngleBracketedArg>> {
|
||||
// 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<AngleBracketedArg>> {
|
||||
let mut args = Vec::new();
|
||||
) -> PResult<'a, ThinVec<AngleBracketedArg>> {
|
||||
let mut args = ThinVec::new();
|
||||
while let Some(arg) = self.parse_angle_arg(ty_generics)? {
|
||||
args.push(arg);
|
||||
if !self.eat(&token::Comma) {
|
||||
|
Loading…
Reference in New Issue
Block a user