Skip to content

Commit 37d62fb

Browse files
author
Lukas Markeffsky
committed
don't remove args for function calls coming from macro expansions
1 parent 3694fd0 commit 37d62fb

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
929929
};
930930
labels.push((provided_span, format!("unexpected argument{provided_ty_name}")));
931931
let mut span = provided_span;
932-
if span.can_be_used_for_suggestions() {
932+
if span.can_be_used_for_suggestions()
933+
&& error_span.can_be_used_for_suggestions()
934+
{
933935
if arg_idx.index() > 0
934936
&& let Some((_, prev)) = provided_arg_tys
935937
.get(ProvidedIdx::from_usize(arg_idx.index() - 1)

tests/ui/argument-suggestions/extra_arguments.stderr

+1-12
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ LL | foo!(1, ~);
258258
| ----------
259259
| | |
260260
| | unexpected argument of type `{integer}`
261-
| | help: remove the extra argument
262261
| in this macro invocation
263262
|
264263
note: function defined here
@@ -272,9 +271,7 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
272271
--> $DIR/extra_arguments.rs:14:9
273272
|
274273
LL | empty(1, $y);
275-
| ^^^^^ ----- help: remove the extra argument
276-
| |
277-
| unexpected argument of type `{integer}`
274+
| ^^^^^ - unexpected argument of type `{integer}`
278275
...
279276
LL | foo!(~, 1);
280277
| ----------
@@ -308,14 +305,6 @@ note: function defined here
308305
LL | fn empty() {}
309306
| ^^^^^
310307
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
311-
help: remove the extra arguments
312-
|
313-
LL ~ empty($x, $y;
314-
LL | };
315-
...
316-
LL | foo!(~, 1);
317-
LL ~ foo!(, 1);
318-
|
319308

320309
error[E0061]: this function takes 1 argument but 2 arguments were supplied
321310
--> $DIR/extra_arguments.rs:53:3

0 commit comments

Comments
 (0)