@@ -80,23 +80,23 @@ pub(crate) fn substs_to_args(
8080 substs : & [ ty:: subst:: GenericArg < ' _ > ] ,
8181 mut skip_first : bool ,
8282) -> Vec < GenericArg > {
83- substs
84- . iter ( )
85- . filter_map ( |kind| match kind. unpack ( ) {
86- GenericArgKind :: Lifetime ( lt) => match * lt {
87- ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrAnon ( _) , .. } ) => {
88- Some ( GenericArg :: Lifetime ( Lifetime :: elided ( ) ) )
89- }
90- _ => lt. clean ( cx) . map ( GenericArg :: Lifetime ) ,
91- } ,
92- GenericArgKind :: Type ( _) if skip_first => {
93- skip_first = false ;
94- None
83+ let mut ret_val =
84+ Vec :: with_capacity ( substs. len ( ) . saturating_sub ( if skip_first { 1 } else { 0 } ) ) ;
85+ ret_val. extend ( substs. iter ( ) . filter_map ( |kind| match kind. unpack ( ) {
86+ GenericArgKind :: Lifetime ( lt) => match * lt {
87+ ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrAnon ( _) , .. } ) => {
88+ Some ( GenericArg :: Lifetime ( Lifetime :: elided ( ) ) )
9589 }
96- GenericArgKind :: Type ( ty) => Some ( GenericArg :: Type ( ty. clean ( cx) ) ) ,
97- GenericArgKind :: Const ( ct) => Some ( GenericArg :: Const ( Box :: new ( ct. clean ( cx) ) ) ) ,
98- } )
99- . collect ( )
90+ _ => lt. clean ( cx) . map ( GenericArg :: Lifetime ) ,
91+ } ,
92+ GenericArgKind :: Type ( _) if skip_first => {
93+ skip_first = false ;
94+ None
95+ }
96+ GenericArgKind :: Type ( ty) => Some ( GenericArg :: Type ( ty. clean ( cx) ) ) ,
97+ GenericArgKind :: Const ( ct) => Some ( GenericArg :: Const ( Box :: new ( ct. clean ( cx) ) ) ) ,
98+ } ) ) ;
99+ ret_val
100100}
101101
102102fn external_generic_args (
0 commit comments