about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2022-12-31 23:13:36 -0800
committerEsteban Küber <esteban@kuber.com.ar>2023-02-14 20:22:09 +0000
commitf02d8ec15eb430700b8181f4733b905e8e4ccca7 (patch)
tree267af0e22ea166bcbd9c67e0e8a44d6fcfe9d65e
parent9bb6e60d1f1360234aae90c97964c0fa5524f141 (diff)
downloadrust-f02d8ec15eb430700b8181f4733b905e8e4ccca7.tar.gz
rust-f02d8ec15eb430700b8181f4733b905e8e4ccca7.zip
More accurate spans for arg removal suggestion
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs3
-rw-r--r--compiler/rustc_errors/src/emitter.rs3
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs98
-rw-r--r--tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr6
-rw-r--r--tests/ui/argument-suggestions/basic.stderr5
-rw-r--r--tests/ui/argument-suggestions/exotic-calls.stderr20
-rw-r--r--tests/ui/argument-suggestions/extra_arguments.stderr70
-rw-r--r--tests/ui/argument-suggestions/issue-97484.stderr5
-rw-r--r--tests/ui/argument-suggestions/mixed_cases.stderr5
-rw-r--r--tests/ui/error-codes/E0057.stderr5
-rw-r--r--tests/ui/issues/issue-16939.stderr5
-rw-r--r--tests/ui/issues/issue-26094.stderr5
-rw-r--r--tests/ui/issues/issue-4935.stderr5
-rw-r--r--tests/ui/methods/method-call-err-msg.stderr5
-rw-r--r--tests/ui/mismatched_types/overloaded-calls-bad.stderr5
-rw-r--r--tests/ui/resolve/resolve-primitive-fallback.stderr5
-rw-r--r--tests/ui/span/issue-34264.stderr10
-rw-r--r--tests/ui/suggestions/args-instead-of-tuple-errors.stderr10
-rw-r--r--tests/ui/tuple/wrong_argument_ice-3.stderr5
-rw-r--r--tests/ui/tuple/wrong_argument_ice-4.stderr5
-rw-r--r--tests/ui/type/type-ascription-instead-of-initializer.stderr5
-rw-r--r--tests/ui/typeck/remove-extra-argument.stderr5
-rw-r--r--tests/ui/typeck/struct-enum-wrong-args.stderr20
23 files changed, 202 insertions, 108 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 9ed8ab67431..5b2786fbb17 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -612,7 +612,7 @@ impl Diagnostic {
     pub fn multipart_suggestion_with_style(
         &mut self,
         msg: impl Into<SubdiagnosticMessage>,
-        suggestion: Vec<(Span, String)>,
+        mut suggestion: Vec<(Span, String)>,
         applicability: Applicability,
         style: SuggestionStyle,
     ) -> &mut Self {
@@ -634,6 +634,7 @@ impl Diagnostic {
             None,
             "suggestion must not have overlapping parts",
         );
+        suggestion.sort_by_key(|(span, _)| (span.lo(), span.hi()));
 
         self.push_suggestion(CodeSuggestion {
             substitutions: vec![Substitution { parts }],
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 4f2cc8b0351..211bbf4f50e 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -1768,7 +1768,7 @@ impl EmitterWriter {
 
         // Render the replacements for each suggestion
         let suggestions = suggestion.splice_lines(sm);
-        debug!("emit_suggestion_default: suggestions={:?}", suggestions);
+        debug!(?suggestions);
 
         if suggestions.is_empty() {
             // Suggestions coming from macros can have malformed spans. This is a heavy handed
@@ -1797,6 +1797,7 @@ impl EmitterWriter {
         for (complete, parts, highlights, only_capitalization) in
             suggestions.iter().take(MAX_SUGGESTIONS)
         {
+            debug!(?complete, ?parts, ?highlights);
             notice_capitalization |= only_capitalization;
 
             let has_deletion = parts.iter().any(|p| p.is_deletion(sm));
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 9c7a84ce198..5c5ed2929c0 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -755,15 +755,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         }
 
         errors.drain_filter(|error| {
-                let Error::Invalid(provided_idx, expected_idx, Compatibility::Incompatible(Some(e))) = error else { return false };
-                let (provided_ty, provided_span) = provided_arg_tys[*provided_idx];
-                let trace = mk_trace(provided_span, formal_and_expected_inputs[*expected_idx], provided_ty);
-                if !matches!(trace.cause.as_failure_code(*e), FailureCode::Error0308(_)) {
-                    self.err_ctxt().report_and_explain_type_error(trace, *e).emit();
-                    return true;
-                }
-                false
-            });
+            let Error::Invalid(
+                provided_idx,
+                expected_idx,
+                Compatibility::Incompatible(Some(e)),
+            ) = error else { return false };
+            let (provided_ty, provided_span) = provided_arg_tys[*provided_idx];
+            let trace = mk_trace(
+                provided_span,
+                formal_and_expected_inputs[*expected_idx],
+                provided_ty,
+            );
+            if !matches!(trace.cause.as_failure_code(*e), FailureCode::Error0308(_)) {
+                self.err_ctxt().report_and_explain_type_error(trace, *e).emit();
+                return true;
+            }
+            false
+        });
 
         // We're done if we found errors, but we already emitted them.
         if errors.is_empty() {
@@ -864,7 +872,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         }
         let mut suggestion_text = SuggestionText::None;
 
+        let ty_to_snippet = |ty: Ty<'tcx>, expected_idx: ExpectedIdx| {
+            if ty.is_unit() {
+                "()".to_string()
+            } else if ty.is_suggestable(tcx, false) {
+                format!("/* {} */", ty)
+            } else if let Some(fn_def_id) = fn_def_id
+                && self.tcx.def_kind(fn_def_id).is_fn_like()
+                && let self_implicit =
+                    matches!(call_expr.kind, hir::ExprKind::MethodCall(..)) as usize
+                && let Some(arg) = self.tcx.fn_arg_names(fn_def_id)
+                    .get(expected_idx.as_usize() + self_implicit)
+                && arg.name != kw::SelfLower
+            {
+                format!("/* {} */", arg.name)
+            } else {
+                "/* value */".to_string()
+            }
+        };
+
         let mut errors = errors.into_iter().peekable();
+        let mut suggestions = vec![];
         while let Some(error) = errors.next() {
             match error {
                 Error::Invalid(provided_idx, expected_idx, compatibility) => {
@@ -906,6 +934,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     };
                     labels
                         .push((provided_span, format!("argument{} unexpected", provided_ty_name)));
+                    let mut span = provided_span;
+                    if let Some((_, next)) = provided_arg_tys.get(
+                        ProvidedIdx::from_usize(arg_idx.index() + 1),
+                    ) {
+                        // Include next comma
+                        span = span.until(*next);
+                    } else if arg_idx.index() > 0
+                        && let Some((_, prev)) = provided_arg_tys
+                            .get(ProvidedIdx::from_usize(arg_idx.index() - 1)
+                    ) {
+                        // Last argument, include previous comma
+                        span = span.with_lo(prev.hi());
+                    }
+                    suggestions.push((span, String::new()));
+
                     suggestion_text = match suggestion_text {
                         SuggestionText::None => SuggestionText::Remove(false),
                         SuggestionText::Remove(_) => SuggestionText::Remove(true),
@@ -1095,6 +1138,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             }
         }
 
+        // Incorporate the argument changes in the removal suggestion.
+        let mut prev = -1;
+        for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
+            if let Some(provided_idx) = provided_idx {
+                prev = provided_idx.index() as i64;
+            }
+            let idx = ProvidedIdx::from_usize((prev + 1) as usize);
+            if let None = provided_idx
+                && let Some((_, arg_span)) = provided_arg_tys.get(idx)
+            {
+                let (_, expected_ty) = formal_and_expected_inputs[expected_idx];
+                suggestions.push((*arg_span, ty_to_snippet(expected_ty, expected_idx)));
+            }
+        }
+
         // If we have less than 5 things to say, it would be useful to call out exactly what's wrong
         if labels.len() <= 5 {
             for (span, label) in labels {
@@ -1112,7 +1170,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 Some(format!("provide the argument{}", if plural { "s" } else { "" }))
             }
             SuggestionText::Remove(plural) => {
-                Some(format!("remove the extra argument{}", if plural { "s" } else { "" }))
+                err.multipart_suggestion_verbose(
+                    &format!("remove the extra argument{}", if plural { "s" } else { "" }),
+                    suggestions,
+                    Applicability::HasPlaceholders,
+                );
+                None
             }
             SuggestionText::Swap => Some("swap these arguments".to_string()),
             SuggestionText::Reorder => Some("reorder these arguments".to_string()),
@@ -1151,20 +1214,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 } else {
                     // Propose a placeholder of the correct type
                     let (_, expected_ty) = formal_and_expected_inputs[expected_idx];
-                    if expected_ty.is_unit() {
-                        "()".to_string()
-                    } else if expected_ty.is_suggestable(tcx, false) {
-                        format!("/* {} */", expected_ty)
-                    } else if let Some(fn_def_id) = fn_def_id
-                        && self.tcx.def_kind(fn_def_id).is_fn_like()
-                        && let self_implicit = matches!(call_expr.kind, hir::ExprKind::MethodCall(..)) as usize
-                        && let Some(arg) = self.tcx.fn_arg_names(fn_def_id).get(expected_idx.as_usize() + self_implicit)
-                        && arg.name != kw::SelfLower
-                    {
-                        format!("/* {} */", arg.name)
-                    } else {
-                        "/* value */".to_string()
-                    }
+                    ty_to_snippet(expected_ty, expected_idx)
                 };
                 suggestion += &suggestion_text;
             }
diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr
index 77ea8ef0520..147e7e246af 100644
--- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr
+++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr
@@ -17,8 +17,10 @@ LL | fn oom() -> ! {
    = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: remove the extra argument
    |
-LL | fn oom() -> !() {
-   |              ++
+LL - fn oom() -> ! {
+LL -     loop {}
+LL - }
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/argument-suggestions/basic.stderr b/tests/ui/argument-suggestions/basic.stderr
index 062b3768858..5333483e2e9 100644
--- a/tests/ui/argument-suggestions/basic.stderr
+++ b/tests/ui/argument-suggestions/basic.stderr
@@ -25,8 +25,9 @@ LL | fn extra() {}
    |    ^^^^^
 help: remove the extra argument
    |
-LL |     extra();
-   |          ~~
+LL -     extra("");
+LL +     extra();
+   |
 
 error[E0061]: this function takes 1 argument but 0 arguments were supplied
   --> $DIR/basic.rs:22:5
diff --git a/tests/ui/argument-suggestions/exotic-calls.stderr b/tests/ui/argument-suggestions/exotic-calls.stderr
index 0580e53c510..f46894ba4c7 100644
--- a/tests/ui/argument-suggestions/exotic-calls.stderr
+++ b/tests/ui/argument-suggestions/exotic-calls.stderr
@@ -11,8 +11,9 @@ LL | fn foo<T: Fn()>(t: T) {
    |           ^^^^
 help: remove the extra argument
    |
-LL |     t();
-   |      ~~
+LL -     t(1i32);
+LL +     t();
+   |
 
 error[E0057]: this function takes 0 arguments but 1 argument was supplied
   --> $DIR/exotic-calls.rs:7:5
@@ -27,8 +28,9 @@ LL | fn bar(t: impl Fn()) {
    |           ^^^^^^^^^
 help: remove the extra argument
    |
-LL |     t();
-   |      ~~
+LL -     t(1i32);
+LL +     t();
+   |
 
 error[E0057]: this function takes 0 arguments but 1 argument was supplied
   --> $DIR/exotic-calls.rs:16:5
@@ -43,8 +45,9 @@ LL | fn baz() -> impl Fn() {
    |             ^^^^^^^^^
 help: remove the extra argument
    |
-LL |     baz()()
-   |          ~~
+LL -     baz()(1i32)
+LL +     baz()()
+   |
 
 error[E0057]: this function takes 0 arguments but 1 argument was supplied
   --> $DIR/exotic-calls.rs:22:5
@@ -59,8 +62,9 @@ LL |     let x = || {};
    |             ^^
 help: remove the extra argument
    |
-LL |     x();
-   |      ~~
+LL -     x(1i32);
+LL +     x();
+   |
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr
index 48787b0c352..0d4f2239917 100644
--- a/tests/ui/argument-suggestions/extra_arguments.stderr
+++ b/tests/ui/argument-suggestions/extra_arguments.stderr
@@ -11,8 +11,9 @@ LL | fn empty() {}
    |    ^^^^^
 help: remove the extra argument
    |
-LL |   empty();
-   |        ~~
+LL -   empty("");
+LL +   empty();
+   |
 
 error[E0061]: this function takes 1 argument but 2 arguments were supplied
   --> $DIR/extra_arguments.rs:9:3
@@ -27,8 +28,9 @@ LL | fn one_arg(_a: i32) {}
    |    ^^^^^^^ -------
 help: remove the extra argument
    |
-LL |   one_arg(1);
-   |          ~~~
+LL -   one_arg(1, 1);
+LL +   one_arg(1);
+   |
 
 error[E0061]: this function takes 1 argument but 2 arguments were supplied
   --> $DIR/extra_arguments.rs:10:3
@@ -43,8 +45,9 @@ LL | fn one_arg(_a: i32) {}
    |    ^^^^^^^ -------
 help: remove the extra argument
    |
-LL |   one_arg(1);
-   |          ~~~
+LL -   one_arg(1, "");
+LL +   one_arg(1);
+   |
 
 error[E0061]: this function takes 1 argument but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:11:3
@@ -61,8 +64,9 @@ LL | fn one_arg(_a: i32) {}
    |    ^^^^^^^ -------
 help: remove the extra arguments
    |
-LL |   one_arg(1);
-   |          ~~~
+LL -   one_arg(1, "", 1.0);
+LL +   one_arg(1, );
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:13:3
@@ -77,8 +81,9 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
    |    ^^^^^^^^^^^^ -------  -------
 help: remove the extra argument
    |
-LL |   two_arg_same(1, 1);
-   |               ~~~~~~
+LL -   two_arg_same(1, 1, 1);
+LL +   two_arg_same(1, 1);
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:14:3
@@ -93,8 +98,9 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
    |    ^^^^^^^^^^^^ -------  -------
 help: remove the extra argument
    |
-LL |   two_arg_same(1, 1);
-   |               ~~~~~~
+LL -   two_arg_same(1, 1, 1.0);
+LL +   two_arg_same(1, 1);
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:16:3
@@ -109,8 +115,9 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
    |    ^^^^^^^^^^^^ -------  --------
 help: remove the extra argument
    |
-LL |   two_arg_diff(1, "");
-   |               ~~~~~~~
+LL -   two_arg_diff(1, 1, "");
+LL +   two_arg_diff(1, "");
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:17:3
@@ -125,8 +132,9 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
    |    ^^^^^^^^^^^^ -------  --------
 help: remove the extra argument
    |
-LL |   two_arg_diff(1, "");
-   |               ~~~~~~~
+LL -   two_arg_diff(1, "", "");
+LL +   two_arg_diff(1, "");
+   |
 
 error[E0061]: this function takes 2 arguments but 4 arguments were supplied
   --> $DIR/extra_arguments.rs:18:3
@@ -143,8 +151,9 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
    |    ^^^^^^^^^^^^ -------  --------
 help: remove the extra arguments
    |
-LL |   two_arg_diff(1, "");
-   |               ~~~~~~~
+LL -   two_arg_diff(1, 1, "", "");
+LL +   two_arg_diff(1, "");
+   |
 
 error[E0061]: this function takes 2 arguments but 4 arguments were supplied
   --> $DIR/extra_arguments.rs:19:3
@@ -161,8 +170,9 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
    |    ^^^^^^^^^^^^ -------  --------
 help: remove the extra arguments
    |
-LL |   two_arg_diff(1, "");
-   |               ~~~~~~~
+LL -   two_arg_diff(1, "", 1, "");
+LL +   two_arg_diff(1, "", );
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:22:3
@@ -177,8 +187,9 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
    |    ^^^^^^^^^^^^ -------  -------
 help: remove the extra argument
    |
-LL |   two_arg_same(1, 1);
-   |               ~~~~~~
+LL -   two_arg_same(1, 1,     "");
+LL +   two_arg_same(1, 1);
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:23:3
@@ -193,8 +204,9 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
    |    ^^^^^^^^^^^^ -------  --------
 help: remove the extra argument
    |
-LL |   two_arg_diff(1, "");
-   |               ~~~~~~~
+LL -   two_arg_diff(1, 1,     "");
+LL +   two_arg_diff(1, "");
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:24:3
@@ -212,8 +224,9 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
    |    ^^^^^^^^^^^^ -------  -------
 help: remove the extra argument
    |
-LL |   two_arg_same(1, 1);
-   |               ~~~~~~
+LL -     1,
+LL +     1
+   |
 
 error[E0061]: this function takes 2 arguments but 3 arguments were supplied
   --> $DIR/extra_arguments.rs:30:3
@@ -231,8 +244,9 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
    |    ^^^^^^^^^^^^ -------  --------
 help: remove the extra argument
    |
-LL |   two_arg_diff(1, "");
-   |               ~~~~~~~
+LL -     1,
+LL +     ""
+   |
 
 error: aborting due to 14 previous errors
 
diff --git a/tests/ui/argument-suggestions/issue-97484.stderr b/tests/ui/argument-suggestions/issue-97484.stderr
index c2e6e001b17..95795a50fce 100644
--- a/tests/ui/argument-suggestions/issue-97484.stderr
+++ b/tests/ui/argument-suggestions/issue-97484.stderr
@@ -19,8 +19,9 @@ LL |     foo(&&A, B, C, D, &E, F, G);
    |                       ~~
 help: remove the extra arguments
    |
-LL |     foo(&&A, D, /* &E */, G);
-   |        ~~~~~~~~~~~~~~~~~~~~~
+LL -     foo(&&A, B, C, D, E, F, G);
+LL +     foo(&&A, D, /* &E */, G);
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/argument-suggestions/mixed_cases.stderr b/tests/ui/argument-suggestions/mixed_cases.stderr
index 8cf48060a63..39eae28b8ca 100644
--- a/tests/ui/argument-suggestions/mixed_cases.stderr
+++ b/tests/ui/argument-suggestions/mixed_cases.stderr
@@ -13,8 +13,9 @@ LL | fn two_args(_a: i32, _b: f32) {}
    |    ^^^^^^^^ -------  -------
 help: remove the extra argument
    |
-LL |   two_args(1, /* f32 */);
-   |           ~~~~~~~~~~~~~~
+LL -   two_args(1, "", X {});
+LL +   two_args(1, /* f32 */);
+   |
 
 error[E0061]: this function takes 3 arguments but 4 arguments were supplied
   --> $DIR/mixed_cases.rs:11:3
diff --git a/tests/ui/error-codes/E0057.stderr b/tests/ui/error-codes/E0057.stderr
index 163737895fe..fc973cd5ef5 100644
--- a/tests/ui/error-codes/E0057.stderr
+++ b/tests/ui/error-codes/E0057.stderr
@@ -27,8 +27,9 @@ LL |     let f = |x| x * 3;
    |             ^^^
 help: remove the extra argument
    |
-LL |     let c = f(2);
-   |              ~~~
+LL -     let c = f(2, 3);
+LL +     let c = f(2);
+   |
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/issues/issue-16939.stderr b/tests/ui/issues/issue-16939.stderr
index 76645645464..92e35b47fc8 100644
--- a/tests/ui/issues/issue-16939.stderr
+++ b/tests/ui/issues/issue-16939.stderr
@@ -11,8 +11,9 @@ LL | fn _foo<F: Fn()> (f: F) {
    |            ^^^^
 help: remove the extra argument
    |
-LL |     |t| f();
-   |          ~~
+LL -     |t| f(t);
+LL +     |t| f();
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/issues/issue-26094.stderr b/tests/ui/issues/issue-26094.stderr
index 881a6e538ee..31bcea83e14 100644
--- a/tests/ui/issues/issue-26094.stderr
+++ b/tests/ui/issues/issue-26094.stderr
@@ -14,8 +14,9 @@ LL | fn some_function() {}
    |    ^^^^^^^^^^^^^
 help: remove the extra argument
    |
-LL |         some_function()
-   |         ~~~~~~~~~~~~~~~
+LL -         $other(None)
+LL +         $other()
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/issues/issue-4935.stderr b/tests/ui/issues/issue-4935.stderr
index bb45fa08338..8b4eeac731b 100644
--- a/tests/ui/issues/issue-4935.stderr
+++ b/tests/ui/issues/issue-4935.stderr
@@ -11,8 +11,9 @@ LL | fn foo(a: usize) {}
    |    ^^^ --------
 help: remove the extra argument
    |
-LL | fn main() { foo(5) }
-   |                ~~~
+LL - fn main() { foo(5, 6) }
+LL + fn main() { foo(5) }
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/methods/method-call-err-msg.stderr b/tests/ui/methods/method-call-err-msg.stderr
index 81269b73b9a..4b312ce28a4 100644
--- a/tests/ui/methods/method-call-err-msg.stderr
+++ b/tests/ui/methods/method-call-err-msg.stderr
@@ -11,8 +11,9 @@ LL |     fn zero(self) -> Foo { self }
    |        ^^^^
 help: remove the extra argument
    |
-LL |     x.zero()
-   |           ~~
+LL -     x.zero(0)
+LL +     x.zero()
+   |
 
 error[E0061]: this method takes 1 argument but 0 arguments were supplied
   --> $DIR/method-call-err-msg.rs:14:7
diff --git a/tests/ui/mismatched_types/overloaded-calls-bad.stderr b/tests/ui/mismatched_types/overloaded-calls-bad.stderr
index 3a895acbdb5..2fa0bd1e096 100644
--- a/tests/ui/mismatched_types/overloaded-calls-bad.stderr
+++ b/tests/ui/mismatched_types/overloaded-calls-bad.stderr
@@ -43,8 +43,9 @@ LL | impl FnMut<(isize,)> for S {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: remove the extra argument
    |
-LL |     let ans = s(/* isize */);
-   |                ~~~~~~~~~~~~~
+LL -     let ans = s("burma", "shave");
+LL +     let ans = s(/* isize */);
+   |
 
 error[E0308]: mismatched types
   --> $DIR/overloaded-calls-bad.rs:40:7
diff --git a/tests/ui/resolve/resolve-primitive-fallback.stderr b/tests/ui/resolve/resolve-primitive-fallback.stderr
index 964302e924c..f46b1073d84 100644
--- a/tests/ui/resolve/resolve-primitive-fallback.stderr
+++ b/tests/ui/resolve/resolve-primitive-fallback.stderr
@@ -30,8 +30,9 @@ note: function defined here
   --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
 help: remove the extra argument
    |
-LL |     std::mem::size_of();
-   |                      ~~
+LL -     std::mem::size_of(u16);
+LL +     std::mem::size_of();
+   |
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/span/issue-34264.stderr b/tests/ui/span/issue-34264.stderr
index 15179954adc..8a27b2dabf1 100644
--- a/tests/ui/span/issue-34264.stderr
+++ b/tests/ui/span/issue-34264.stderr
@@ -63,8 +63,9 @@ LL | fn foo(Option<i32>, String) {}
    |    ^^^ -----------  ------
 help: remove the extra argument
    |
-LL |     foo(Some(42), 2);
-   |        ~~~~~~~~~~~~~
+LL -     foo(Some(42), 2, "");
+LL +     foo(Some(42), 2);
+   |
 
 error[E0308]: mismatched types
   --> $DIR/issue-34264.rs:8:13
@@ -93,8 +94,9 @@ LL | fn bar(x, y: usize) {}
    |    ^^^ -  --------
 help: remove the extra argument
    |
-LL |     bar(1, 2);
-   |        ~~~~~~
+LL -     bar(1, 2, 3);
+LL +     bar(1, 2);
+   |
 
 error: aborting due to 6 previous errors
 
diff --git a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr
index e9736363816..e592f3156cb 100644
--- a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr
+++ b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr
@@ -22,8 +22,9 @@ note: tuple variant defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
 help: remove the extra argument
    |
-LL |     let _: Option<(i32, bool)> = Some(/* (i32, bool) */);
-   |                                      ~~~~~~~~~~~~~~~~~~~
+LL -     let _: Option<(i32, bool)> = Some(1, 2);
+LL +     let _: Option<(i32, bool)> = Some(/* (i32, bool) */);
+   |
 
 error[E0061]: this function takes 1 argument but 2 arguments were supplied
   --> $DIR/args-instead-of-tuple-errors.rs:8:5
@@ -45,8 +46,9 @@ LL | fn int_bool(_: (i32, bool)) {
    |    ^^^^^^^^ --------------
 help: remove the extra argument
    |
-LL |     int_bool(/* (i32, bool) */);
-   |             ~~~~~~~~~~~~~~~~~~~
+LL -     int_bool(1, 2);
+LL +     int_bool(/* (i32, bool) */);
+   |
 
 error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied
   --> $DIR/args-instead-of-tuple-errors.rs:11:28
diff --git a/tests/ui/tuple/wrong_argument_ice-3.stderr b/tests/ui/tuple/wrong_argument_ice-3.stderr
index 75dfe716395..d8ab265cfc9 100644
--- a/tests/ui/tuple/wrong_argument_ice-3.stderr
+++ b/tests/ui/tuple/wrong_argument_ice-3.stderr
@@ -15,8 +15,9 @@ note: associated function defined here
   --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
 help: remove the extra argument
    |
-LL |         groups.push(/* (Vec<String>, Vec<Process>) */);
-   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LL -         groups.push(new_group, vec![process]);
+LL +         groups.push(/* (Vec<String>, Vec<Process>) */);
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/tuple/wrong_argument_ice-4.stderr b/tests/ui/tuple/wrong_argument_ice-4.stderr
index a2686ab9440..1ff4c3d49ed 100644
--- a/tests/ui/tuple/wrong_argument_ice-4.stderr
+++ b/tests/ui/tuple/wrong_argument_ice-4.stderr
@@ -15,8 +15,9 @@ LL |     (|| {})(|| {
    |      ^^
 help: remove the extra argument
    |
-LL |     (|| {})();
-   |            ~~
+LL -     (|| {})(|| {
+LL +     (|| {})();
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/type/type-ascription-instead-of-initializer.stderr b/tests/ui/type/type-ascription-instead-of-initializer.stderr
index ba8d15d0b73..b73d7cd144e 100644
--- a/tests/ui/type/type-ascription-instead-of-initializer.stderr
+++ b/tests/ui/type/type-ascription-instead-of-initializer.stderr
@@ -17,8 +17,9 @@ note: associated function defined here
   --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
 help: remove the extra argument
    |
-LL |     let x: Vec::with_capacity(10);
-   |                              ~~~~
+LL -     let x: Vec::with_capacity(10, 20);
+LL +     let x: Vec::with_capacity(10);
+   |
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/typeck/remove-extra-argument.stderr b/tests/ui/typeck/remove-extra-argument.stderr
index b734bcd4eb0..c9d5c6b9fb2 100644
--- a/tests/ui/typeck/remove-extra-argument.stderr
+++ b/tests/ui/typeck/remove-extra-argument.stderr
@@ -11,8 +11,9 @@ LL | fn l(_a: Vec<u8>) {}
    |    ^ -----------
 help: remove the extra argument
    |
-LL |     l(vec![])
-   |      ~~~~~~~~
+LL -     l(vec![], vec![])
+LL +     l(vec![])
+   |
 
 error: aborting due to previous error
 
diff --git a/tests/ui/typeck/struct-enum-wrong-args.stderr b/tests/ui/typeck/struct-enum-wrong-args.stderr
index fbced928a8a..71672f984c1 100644
--- a/tests/ui/typeck/struct-enum-wrong-args.stderr
+++ b/tests/ui/typeck/struct-enum-wrong-args.stderr
@@ -8,8 +8,9 @@ note: tuple variant defined here
   --> $SRC_DIR/core/src/option.rs:LL:COL
 help: remove the extra argument
    |
-LL |     let _ = Some(3);
-   |                 ~~~
+LL -     let _ = Some(3, 2);
+LL +     let _ = Some(3);
+   |
 
 error[E0061]: this enum variant takes 1 argument but 3 arguments were supplied
   --> $DIR/struct-enum-wrong-args.rs:7:13
@@ -23,8 +24,9 @@ note: tuple variant defined here
   --> $SRC_DIR/core/src/result.rs:LL:COL
 help: remove the extra arguments
    |
-LL |     let _ = Ok(3);
-   |               ~~~
+LL -     let _ = Ok(3, 6, 2);
+LL +     let _ = Ok(3, );
+   |
 
 error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied
   --> $DIR/struct-enum-wrong-args.rs:8:13
@@ -68,8 +70,9 @@ LL | struct Wrapper(i32);
    |        ^^^^^^^
 help: remove the extra argument
    |
-LL |     let _ = Wrapper(5);
-   |                    ~~~
+LL -     let _ = Wrapper(5, 2);
+LL +     let _ = Wrapper(5);
+   |
 
 error[E0061]: this struct takes 2 arguments but 0 arguments were supplied
   --> $DIR/struct-enum-wrong-args.rs:11:13
@@ -116,8 +119,9 @@ LL | struct DoubleWrapper(i32, i32);
    |        ^^^^^^^^^^^^^
 help: remove the extra argument
    |
-LL |     let _ = DoubleWrapper(5, 2);
-   |                          ~~~~~~
+LL -     let _ = DoubleWrapper(5, 2, 7);
+LL +     let _ = DoubleWrapper(5, 2);
+   |
 
 error: aborting due to 8 previous errors