+ let (span, start_span, args) = match &expr.kind {
+ hir::ExprKind::Call(hir::Expr { span, .. }, args) => (*span, *span, &args[..]),
+ hir::ExprKind::MethodCall(path_segment, span, args) => (
+ *span,
+ // `sp` doesn't point at the whole `foo.bar()`, only at `bar`.
+ path_segment
+ .args
+ .and_then(|args| args.args.iter().last())
+ // Account for `foo.bar::<T>()`.
+ .map(|arg| {
+ // Skip the closing `>`.
+ tcx.sess
+ .source_map()
+ .next_point(tcx.sess.source_map().next_point(arg.span()))
+ })
+ .unwrap_or(*span),
+ &args[1..], // Skip the receiver.
+ ),
+ k => span_bug!(sp, "checking argument types on a non-call: `{:?}`", k),
+ };
+ let arg_spans = if args.is_empty() {
+ // foo()
+ // ^^^-- supplied 0 arguments
+ // |
+ // expected 2 arguments
+ vec![tcx.sess.source_map().next_point(start_span).with_hi(sp.hi())]
+ } else {
+ // foo(1, 2, 3)
+ // ^^^ - - - supplied 3 arguments
+ // |
+ // expected 2 arguments
+ args.iter().map(|arg| arg.span).collect::<Vec<Span>>()
+ };
+