@@ -235,7 +235,7 @@ impl<'a> InferenceContext<'a> {
235
235
Expr :: Closure { body, args, ret_type, arg_types, closure_kind } => {
236
236
assert_eq ! ( args. len( ) , arg_types. len( ) ) ;
237
237
238
- let mut sig_tys = Vec :: new ( ) ;
238
+ let mut sig_tys = Vec :: with_capacity ( arg_types . len ( ) + 1 ) ;
239
239
240
240
// collect explicitly written argument types
241
241
for arg_type in arg_types. iter ( ) {
@@ -256,7 +256,8 @@ impl<'a> InferenceContext<'a> {
256
256
num_binders : 0 ,
257
257
sig : FnSig { abi : ( ) , safety : chalk_ir:: Safety :: Safe , variadic : false } ,
258
258
substitution : FnSubst (
259
- Substitution :: from_iter ( Interner , sig_tys. clone ( ) ) . shifted_in ( Interner ) ,
259
+ Substitution :: from_iter ( Interner , sig_tys. iter ( ) . cloned ( ) )
260
+ . shifted_in ( Interner ) ,
260
261
) ,
261
262
} )
262
263
. intern ( Interner ) ;
@@ -318,16 +319,16 @@ impl<'a> InferenceContext<'a> {
318
319
Expr :: Call { callee, args, .. } => {
319
320
let callee_ty = self . infer_expr ( * callee, & Expectation :: none ( ) ) ;
320
321
let mut derefs = Autoderef :: new ( & mut self . table , callee_ty. clone ( ) ) ;
321
- let mut res = None ;
322
- let mut derefed_callee = callee_ty. clone ( ) ;
323
- // manual loop to be able to access `derefs.table`
324
- while let Some ( ( callee_deref_ty, _) ) = derefs. next ( ) {
325
- res = derefs. table . callable_sig ( & callee_deref_ty, args. len ( ) ) ;
326
- if res. is_some ( ) {
327
- derefed_callee = callee_deref_ty;
328
- break ;
322
+ let ( res, derefed_callee) = ' b: {
323
+ // manual loop to be able to access `derefs.table`
324
+ while let Some ( ( callee_deref_ty, _) ) = derefs. next ( ) {
325
+ let res = derefs. table . callable_sig ( & callee_deref_ty, args. len ( ) ) ;
326
+ if res. is_some ( ) {
327
+ break ' b ( res, callee_deref_ty) ;
328
+ }
329
329
}
330
- }
330
+ ( None , callee_ty. clone ( ) )
331
+ } ;
331
332
// if the function is unresolved, we use is_varargs=true to
332
333
// suppress the arg count diagnostic here
333
334
let is_varargs =
0 commit comments