Skip to content

Commit 985036b

Browse files
author
Lukas Markeffsky
committed
add more tests for argument removal with wacky spans
1 parent 37d62fb commit 985036b

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

tests/ui/argument-suggestions/extra_arguments.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn empty() {}
2-
fn one_arg(_a: i32) {}
2+
fn one_arg<T>(_a: T) {}
33
fn two_arg_same(_a: i32, _b: i32) {}
44
fn two_arg_diff(_a: i32, _b: &str) {}
55

@@ -52,4 +52,10 @@ fn main() {
5252
foo!(1, 1);
5353
one_arg(1, panic!()); //~ ERROR function takes
5454
one_arg(panic!(), 1); //~ ERROR function takes
55+
one_arg(stringify!($e), 1); //~ ERROR function takes
56+
57+
// Not a macro, but this also has multiple spans with equal source code,
58+
// but different expansion contexts.
59+
// https://github.com/rust-lang/rust/issues/114255
60+
one_arg(for _ in 1.. {}, 1); //~ ERROR function takes
5561
}

tests/ui/argument-suggestions/extra_arguments.stderr

+41-11
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ LL | one_arg(1, 1);
4444
note: function defined here
4545
--> $DIR/extra_arguments.rs:2:4
4646
|
47-
LL | fn one_arg(_a: i32) {}
48-
| ^^^^^^^ -------
47+
LL | fn one_arg<T>(_a: T) {}
48+
| ^^^^^^^ -----
4949

5050
error[E0061]: this function takes 1 argument but 2 arguments were supplied
5151
--> $DIR/extra_arguments.rs:23:3
@@ -59,8 +59,8 @@ LL | one_arg(1, "");
5959
note: function defined here
6060
--> $DIR/extra_arguments.rs:2:4
6161
|
62-
LL | fn one_arg(_a: i32) {}
63-
| ^^^^^^^ -------
62+
LL | fn one_arg<T>(_a: T) {}
63+
| ^^^^^^^ -----
6464

6565
error[E0061]: this function takes 1 argument but 3 arguments were supplied
6666
--> $DIR/extra_arguments.rs:24:3
@@ -73,8 +73,8 @@ LL | one_arg(1, "", 1.0);
7373
note: function defined here
7474
--> $DIR/extra_arguments.rs:2:4
7575
|
76-
LL | fn one_arg(_a: i32) {}
77-
| ^^^^^^^ -------
76+
LL | fn one_arg<T>(_a: T) {}
77+
| ^^^^^^^ -----
7878
help: remove the extra arguments
7979
|
8080
LL - one_arg(1, "", 1.0);
@@ -318,8 +318,8 @@ LL | one_arg(1, panic!());
318318
note: function defined here
319319
--> $DIR/extra_arguments.rs:2:4
320320
|
321-
LL | fn one_arg(_a: i32) {}
322-
| ^^^^^^^ -------
321+
LL | fn one_arg<T>(_a: T) {}
322+
| ^^^^^^^ -----
323323

324324
error[E0061]: this function takes 1 argument but 2 arguments were supplied
325325
--> $DIR/extra_arguments.rs:54:3
@@ -333,9 +333,39 @@ LL | one_arg(panic!(), 1);
333333
note: function defined here
334334
--> $DIR/extra_arguments.rs:2:4
335335
|
336-
LL | fn one_arg(_a: i32) {}
337-
| ^^^^^^^ -------
336+
LL | fn one_arg<T>(_a: T) {}
337+
| ^^^^^^^ -----
338338

339-
error: aborting due to 20 previous errors
339+
error[E0061]: this function takes 1 argument but 2 arguments were supplied
340+
--> $DIR/extra_arguments.rs:55:3
341+
|
342+
LL | one_arg(stringify!($e), 1);
343+
| ^^^^^^^ ---
344+
| | |
345+
| | unexpected argument of type `{integer}`
346+
| help: remove the extra argument
347+
|
348+
note: function defined here
349+
--> $DIR/extra_arguments.rs:2:4
350+
|
351+
LL | fn one_arg<T>(_a: T) {}
352+
| ^^^^^^^ -----
353+
354+
error[E0061]: this function takes 1 argument but 2 arguments were supplied
355+
--> $DIR/extra_arguments.rs:60:3
356+
|
357+
LL | one_arg(for _ in 1.. {}, 1);
358+
| ^^^^^^^ ---
359+
| | |
360+
| | unexpected argument of type `{integer}`
361+
| help: remove the extra argument
362+
|
363+
note: function defined here
364+
--> $DIR/extra_arguments.rs:2:4
365+
|
366+
LL | fn one_arg<T>(_a: T) {}
367+
| ^^^^^^^ -----
368+
369+
error: aborting due to 22 previous errors
340370

341371
For more information about this error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)