@@ -298,6 +298,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
298
298
// call's arguments and we can provide a more explicit span.
299
299
let sig = self . tcx . fn_sig ( def_id) . subst_identity ( ) ;
300
300
let def_self_ty = sig. input ( 0 ) . skip_binder ( ) ;
301
+ let param_tys = sig. inputs ( ) . skip_binder ( ) . iter ( ) . skip ( 1 ) ;
302
+ // If there's an arity mismatch, pointing out the call as the source of an inference
303
+ // can be misleading, so we skip it.
304
+ if param_tys. len ( ) != args. len ( ) {
305
+ continue ;
306
+ }
301
307
let rcvr_ty = self . node_ty ( rcvr. hir_id ) ;
302
308
// Get the evaluated type *after* calling the method call, so that the influence
303
309
// of the arguments can be reflected in the receiver type. The receiver
@@ -323,7 +329,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
323
329
let mut param_found = FxHashMap :: default ( ) ;
324
330
if self . can_eq ( self . param_env , ty, found) . is_ok ( ) {
325
331
// We only point at the first place where the found type was inferred.
326
- for ( param_ty, arg) in sig . inputs ( ) . skip_binder ( ) . iter ( ) . skip ( 1 ) . zip ( args) {
332
+ for ( param_ty, arg) in param_tys . zip ( args) {
327
333
if def_self_ty. contains ( * param_ty) && let ty:: Param ( _) = param_ty. kind ( ) {
328
334
// We found an argument that references a type parameter in `Self`,
329
335
// so we assume that this is the argument that caused the found
0 commit comments