@@ -399,7 +399,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
399
399
}
400
400
ty:: FnPtr ( sig) => ( sig, None ) ,
401
401
_ => {
402
- let mut skip_first_expr = false ;
402
+ for arg in arg_exprs {
403
+ self . check_expr ( arg) ;
404
+ }
405
+
403
406
if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, path) ) = & callee_expr. kind
404
407
&& let [ segment] = path. segments
405
408
&& let Some ( mut diag) = self
@@ -422,16 +425,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
422
425
return ty;
423
426
} else {
424
427
diag. emit ( ) ;
425
- skip_first_expr = true ;
426
428
}
427
429
}
428
430
429
431
let err = self . report_invalid_callee ( call_expr, callee_expr, callee_ty, arg_exprs) ;
430
432
431
- for arg in arg_exprs. iter ( ) . skip ( skip_first_expr as usize ) {
432
- self . check_expr ( arg) ;
433
- }
434
-
435
433
return self . tcx . ty_error_with_guaranteed ( err) ;
436
434
}
437
435
} ;
@@ -492,9 +490,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
492
490
expected : Expectation < ' tcx > ,
493
491
) -> Option < Ty < ' tcx > > {
494
492
if let [ callee_expr, rest @ ..] = arg_exprs {
495
- // This may happen recursively -- if so, avoid repeatedly checking the expr.
496
- let callee_ty = self . typeck_results . borrow ( ) . expr_ty_adjusted_opt ( callee_expr) ;
497
- let callee_ty = callee_ty. unwrap_or_else ( || self . check_expr ( callee_expr) ) ;
493
+ let callee_ty = self . typeck_results . borrow ( ) . expr_ty_adjusted_opt ( callee_expr) ?;
494
+
498
495
// First, do a probe with `IsSuggestion(true)` to avoid emitting
499
496
// any strange errors. If it's successful, then we'll do a true
500
497
// method lookup.
0 commit comments