don't remove args for function calls coming from macro expansions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 8e49aa3..15bb67d 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -929,7 +929,9 @@
};
labels.push((provided_span, format!("unexpected argument{provided_ty_name}")));
let mut span = provided_span;
- if span.can_be_used_for_suggestions() {
+ if span.can_be_used_for_suggestions()
+ && error_span.can_be_used_for_suggestions()
+ {
if arg_idx.index() > 0
&& let Some((_, prev)) = provided_arg_tys
.get(ProvidedIdx::from_usize(arg_idx.index() - 1)
diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr
index 1016c7b..bd32780 100644
--- a/tests/ui/argument-suggestions/extra_arguments.stderr
+++ b/tests/ui/argument-suggestions/extra_arguments.stderr
@@ -258,7 +258,6 @@
| ----------
| | |
| | unexpected argument of type `{integer}`
- | | help: remove the extra argument
| in this macro invocation
|
note: function defined here
@@ -272,9 +271,7 @@
--> $DIR/extra_arguments.rs:14:9
|
LL | empty(1, $y);
- | ^^^^^ ----- help: remove the extra argument
- | |
- | unexpected argument of type `{integer}`
+ | ^^^^^ - unexpected argument of type `{integer}`
...
LL | foo!(~, 1);
| ----------
@@ -308,14 +305,6 @@
LL | fn empty() {}
| ^^^^^
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: remove the extra arguments
- |
-LL ~ empty($x, $y;
-LL | };
- ...
-LL | foo!(~, 1);
-LL ~ foo!(, 1);
- |
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/extra_arguments.rs:53:3