about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Markeffsky <@>2023-06-10 19:23:40 +0200
committerLukas Markeffsky <@>2023-08-01 16:51:20 +0000
commit37d62fbf9e5bd2010896a28d6b363bd85cbecb33 (patch)
tree047cee6b574d9b4662447ede6c993b1cf0b87f6e
parent3694fd08e6e9d0828369ac1c9ee205cd0de71287 (diff)
downloadrust-37d62fbf9e5bd2010896a28d6b363bd85cbecb33.tar.gz
rust-37d62fbf9e5bd2010896a28d6b363bd85cbecb33.zip
don't remove args for function calls coming from macro expansions
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs4
-rw-r--r--tests/ui/argument-suggestions/extra_arguments.stderr13
2 files changed, 4 insertions, 13 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 8e49aa3e656..15bb67db6e9 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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     };
                     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 1016c7ba438..bd32780c88f 100644
--- a/tests/ui/argument-suggestions/extra_arguments.stderr
+++ b/tests/ui/argument-suggestions/extra_arguments.stderr
@@ -258,7 +258,6 @@ LL |   foo!(1, ~);
    |   ----------
    |   |    |
    |   |    unexpected argument of type `{integer}`
-   |   |    help: remove the extra argument
    |   in this macro invocation
    |
 note: function defined here
@@ -272,9 +271,7 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
   --> $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 @@ note: function defined here
 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