@@ -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 (
@@ -112,8 +112,8 @@ fn external_generic_args(
112112 let inputs =
113113 // The trait's first substitution is the one after self, if there is one.
114114 match substs. iter ( ) . nth ( if has_self { 1 } else { 0 } ) . unwrap ( ) . expect_ty ( ) . kind ( ) {
115- ty:: Tuple ( tys) => tys. iter ( ) . map ( |t| t. clean ( cx) ) . collect ( ) ,
116- _ => return GenericArgs :: AngleBracketed { args, bindings : bindings. into ( ) } ,
115+ ty:: Tuple ( tys) => tys. iter ( ) . map ( |t| t. clean ( cx) ) . collect :: < Vec < _ > > ( ) . into ( ) ,
116+ _ => return GenericArgs :: AngleBracketed { args : args . into ( ) , bindings : bindings. into ( ) } ,
117117 } ;
118118 let output = None ;
119119 // FIXME(#20299) return type comes from a projection now
@@ -123,7 +123,7 @@ fn external_generic_args(
123123 // };
124124 GenericArgs :: Parenthesized { inputs, output }
125125 } else {
126- GenericArgs :: AngleBracketed { args, bindings : bindings. into ( ) }
126+ GenericArgs :: AngleBracketed { args : args . into ( ) , bindings : bindings. into ( ) }
127127 }
128128}
129129
@@ -148,7 +148,7 @@ pub(super) fn external_path(
148148/// Remove the generic arguments from a path.
149149pub ( crate ) fn strip_path_generics ( mut path : Path ) -> Path {
150150 for ps in path. segments . iter_mut ( ) {
151- ps. args = GenericArgs :: AngleBracketed { args : vec ! [ ] , bindings : ThinVec :: new ( ) }
151+ ps. args = GenericArgs :: AngleBracketed { args : Default :: default ( ) , bindings : ThinVec :: new ( ) }
152152 }
153153
154154 path
0 commit comments