@@ -235,7 +235,7 @@ impl<'a> InferenceContext<'a> {
235235 Expr :: Closure { body, args, ret_type, arg_types, closure_kind } => {
236236 assert_eq ! ( args. len( ) , arg_types. len( ) ) ;
237237
238- let mut sig_tys = Vec :: new ( ) ;
238+ let mut sig_tys = Vec :: with_capacity ( arg_types . len ( ) + 1 ) ;
239239
240240 // collect explicitly written argument types
241241 for arg_type in arg_types. iter ( ) {
@@ -256,7 +256,8 @@ impl<'a> InferenceContext<'a> {
256256 num_binders : 0 ,
257257 sig : FnSig { abi : ( ) , safety : chalk_ir:: Safety :: Safe , variadic : false } ,
258258 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 ) ,
260261 ) ,
261262 } )
262263 . intern ( Interner ) ;
@@ -318,16 +319,16 @@ impl<'a> InferenceContext<'a> {
318319 Expr :: Call { callee, args, .. } => {
319320 let callee_ty = self . infer_expr ( * callee, & Expectation :: none ( ) ) ;
320321 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+ }
329329 }
330- }
330+ ( None , callee_ty. clone ( ) )
331+ } ;
331332 // if the function is unresolved, we use is_varargs=true to
332333 // suppress the arg count diagnostic here
333334 let is_varargs =
0 commit comments