@@ -208,7 +208,12 @@ pub(super) fn lower_generic_args(
208
208
if args. is_empty ( ) && bindings. is_empty ( ) {
209
209
return None ;
210
210
}
211
- Some ( GenericArgs { args, has_self_type : false , bindings, desugared_from_fn : false } )
211
+ Some ( GenericArgs {
212
+ args,
213
+ has_self_type : false ,
214
+ bindings : bindings. into_boxed_slice ( ) ,
215
+ desugared_from_fn : false ,
216
+ } )
212
217
}
213
218
214
219
/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
@@ -219,7 +224,6 @@ fn lower_generic_args_from_fn_path(
219
224
ret_type : Option < ast:: RetType > ,
220
225
) -> Option < GenericArgs > {
221
226
let mut args = Vec :: new ( ) ;
222
- let mut bindings = Vec :: new ( ) ;
223
227
let params = params?;
224
228
let mut param_types = Vec :: new ( ) ;
225
229
for param in params. params ( ) {
@@ -228,23 +232,23 @@ fn lower_generic_args_from_fn_path(
228
232
}
229
233
let arg = GenericArg :: Type ( TypeRef :: Tuple ( param_types) ) ;
230
234
args. push ( arg) ;
231
- if let Some ( ret_type) = ret_type {
235
+ let bindings = if let Some ( ret_type) = ret_type {
232
236
let type_ref = TypeRef :: from_ast_opt ( ctx, ret_type. ty ( ) ) ;
233
- bindings . push ( AssociatedTypeBinding {
237
+ Box :: new ( [ AssociatedTypeBinding {
234
238
name : name ! [ Output ] ,
235
239
args : None ,
236
240
type_ref : Some ( type_ref) ,
237
241
bounds : Box :: default ( ) ,
238
- } ) ;
242
+ } ] )
239
243
} else {
240
244
// -> ()
241
245
let type_ref = TypeRef :: Tuple ( Vec :: new ( ) ) ;
242
- bindings . push ( AssociatedTypeBinding {
246
+ Box :: new ( [ AssociatedTypeBinding {
243
247
name : name ! [ Output ] ,
244
248
args : None ,
245
249
type_ref : Some ( type_ref) ,
246
250
bounds : Box :: default ( ) ,
247
- } ) ;
248
- }
251
+ } ] )
252
+ } ;
249
253
Some ( GenericArgs { args, has_self_type : false , bindings, desugared_from_fn : true } )
250
254
}
0 commit comments