@@ -80,23 +80,23 @@ pub(crate) fn substs_to_args(
80
80
substs : & [ ty:: subst:: GenericArg < ' _ > ] ,
81
81
mut skip_first : bool ,
82
82
) -> 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 ( ) ) )
95
89
}
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
100
100
}
101
101
102
102
fn external_generic_args (
@@ -112,8 +112,8 @@ fn external_generic_args(
112
112
let inputs =
113
113
// The trait's first substitution is the one after self, if there is one.
114
114
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 ( ) } ,
117
117
} ;
118
118
let output = None ;
119
119
// FIXME(#20299) return type comes from a projection now
@@ -123,7 +123,7 @@ fn external_generic_args(
123
123
// };
124
124
GenericArgs :: Parenthesized { inputs, output }
125
125
} else {
126
- GenericArgs :: AngleBracketed { args, bindings : bindings. into ( ) }
126
+ GenericArgs :: AngleBracketed { args : args . into ( ) , bindings : bindings. into ( ) }
127
127
}
128
128
}
129
129
@@ -148,7 +148,7 @@ pub(super) fn external_path(
148
148
/// Remove the generic arguments from a path.
149
149
pub ( crate ) fn strip_path_generics ( mut path : Path ) -> Path {
150
150
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 ( ) }
152
152
}
153
153
154
154
path
0 commit comments