Skip to content

Commit 10ef96f

Browse files
author
Lukas Markeffsky
committed
add macro test cases to extra arguments test
1 parent 89acdae commit 10ef96f

File tree

2 files changed

+108
-21
lines changed

2 files changed

+108
-21
lines changed

tests/ui/argument-suggestions/extra_arguments.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ fn two_arg_same(_a: i32, _b: i32) {}
44
fn two_arg_diff(_a: i32, _b: &str) {}
55

66
macro_rules! foo {
7-
($x:expr) => {
7+
($x:expr, ~) => {
88
empty($x, 1); //~ ERROR function takes
9-
}
9+
};
10+
($x:expr, $y:expr) => {
11+
empty($x, $y); //~ ERROR function takes
12+
};
13+
(~, $y:expr) => {
14+
empty(1, $y); //~ ERROR function takes
15+
};
1016
}
1117

1218
fn main() {
@@ -39,5 +45,11 @@ fn main() {
3945
1,
4046
""
4147
);
42-
foo!(1);
48+
49+
// Check with macro expansions
50+
foo!(1, ~);
51+
foo!(~, 1);
52+
foo!(1, 1);
53+
one_arg(1, panic!()); //~ ERROR function takes
54+
one_arg(panic!(), 1); //~ ERROR function takes
4355
}

tests/ui/argument-suggestions/extra_arguments.stderr

+93-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0061]: this function takes 0 arguments but 1 argument was supplied
2-
--> $DIR/extra_arguments.rs:13:3
2+
--> $DIR/extra_arguments.rs:19:3
33
|
44
LL | empty("");
55
| ^^^^^ --
@@ -14,7 +14,7 @@ LL | fn empty() {}
1414
| ^^^^^
1515

1616
error[E0061]: this function takes 0 arguments but 2 arguments were supplied
17-
--> $DIR/extra_arguments.rs:14:3
17+
--> $DIR/extra_arguments.rs:20:3
1818
|
1919
LL | empty(1, 1);
2020
| ^^^^^ - - unexpected argument of type `{integer}`
@@ -33,7 +33,7 @@ LL + empty();
3333
|
3434

3535
error[E0061]: this function takes 1 argument but 2 arguments were supplied
36-
--> $DIR/extra_arguments.rs:16:3
36+
--> $DIR/extra_arguments.rs:22:3
3737
|
3838
LL | one_arg(1, 1);
3939
| ^^^^^^^ ---
@@ -48,7 +48,7 @@ LL | fn one_arg(_a: i32) {}
4848
| ^^^^^^^ -------
4949

5050
error[E0061]: this function takes 1 argument but 2 arguments were supplied
51-
--> $DIR/extra_arguments.rs:17:3
51+
--> $DIR/extra_arguments.rs:23:3
5252
|
5353
LL | one_arg(1, "");
5454
| ^^^^^^^ ----
@@ -63,7 +63,7 @@ LL | fn one_arg(_a: i32) {}
6363
| ^^^^^^^ -------
6464

6565
error[E0061]: this function takes 1 argument but 3 arguments were supplied
66-
--> $DIR/extra_arguments.rs:18:3
66+
--> $DIR/extra_arguments.rs:24:3
6767
|
6868
LL | one_arg(1, "", 1.0);
6969
| ^^^^^^^ -- --- unexpected argument of type `{float}`
@@ -82,7 +82,7 @@ LL + one_arg(1);
8282
|
8383

8484
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
85-
--> $DIR/extra_arguments.rs:20:3
85+
--> $DIR/extra_arguments.rs:26:3
8686
|
8787
LL | two_arg_same(1, 1, 1);
8888
| ^^^^^^^^^^^^ ---
@@ -97,7 +97,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
9797
| ^^^^^^^^^^^^ ------- -------
9898

9999
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
100-
--> $DIR/extra_arguments.rs:21:3
100+
--> $DIR/extra_arguments.rs:27:3
101101
|
102102
LL | two_arg_same(1, 1, 1.0);
103103
| ^^^^^^^^^^^^ -----
@@ -112,7 +112,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
112112
| ^^^^^^^^^^^^ ------- -------
113113

114114
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
115-
--> $DIR/extra_arguments.rs:23:3
115+
--> $DIR/extra_arguments.rs:29:3
116116
|
117117
LL | two_arg_diff(1, 1, "");
118118
| ^^^^^^^^^^^^ ---
@@ -127,7 +127,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
127127
| ^^^^^^^^^^^^ ------- --------
128128

129129
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
130-
--> $DIR/extra_arguments.rs:24:3
130+
--> $DIR/extra_arguments.rs:30:3
131131
|
132132
LL | two_arg_diff(1, "", "");
133133
| ^^^^^^^^^^^^ ----
@@ -142,7 +142,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
142142
| ^^^^^^^^^^^^ ------- --------
143143

144144
error[E0061]: this function takes 2 arguments but 4 arguments were supplied
145-
--> $DIR/extra_arguments.rs:25:3
145+
--> $DIR/extra_arguments.rs:31:3
146146
|
147147
LL | two_arg_diff(1, 1, "", "");
148148
| ^^^^^^^^^^^^ - -- unexpected argument of type `&'static str`
@@ -161,7 +161,7 @@ LL + two_arg_diff(1, "");
161161
|
162162

163163
error[E0061]: this function takes 2 arguments but 4 arguments were supplied
164-
--> $DIR/extra_arguments.rs:26:3
164+
--> $DIR/extra_arguments.rs:32:3
165165
|
166166
LL | two_arg_diff(1, "", 1, "");
167167
| ^^^^^^^^^^^^ - -- unexpected argument of type `&'static str`
@@ -180,7 +180,7 @@ LL + two_arg_diff(1, "");
180180
|
181181

182182
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
183-
--> $DIR/extra_arguments.rs:29:3
183+
--> $DIR/extra_arguments.rs:35:3
184184
|
185185
LL | two_arg_same(1, 1, "");
186186
| ^^^^^^^^^^^^ --------
@@ -195,7 +195,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
195195
| ^^^^^^^^^^^^ ------- -------
196196

197197
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
198-
--> $DIR/extra_arguments.rs:30:3
198+
--> $DIR/extra_arguments.rs:36:3
199199
|
200200
LL | two_arg_diff(1, 1, "");
201201
| ^^^^^^^^^^^^ ---
@@ -210,7 +210,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {}
210210
| ^^^^^^^^^^^^ ------- --------
211211

212212
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
213-
--> $DIR/extra_arguments.rs:31:3
213+
--> $DIR/extra_arguments.rs:37:3
214214
|
215215
LL | two_arg_same(
216216
| ^^^^^^^^^^^^
@@ -230,7 +230,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {}
230230
| ^^^^^^^^^^^^ ------- -------
231231

232232
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
233-
--> $DIR/extra_arguments.rs:37:3
233+
--> $DIR/extra_arguments.rs:43:3
234234
|
235235
LL | two_arg_diff(
236236
| ^^^^^^^^^^^^
@@ -254,8 +254,8 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
254254
LL | empty($x, 1);
255255
| ^^^^^ - unexpected argument of type `{integer}`
256256
...
257-
LL | foo!(1);
258-
| -------
257+
LL | foo!(1, ~);
258+
| ----------
259259
| | |
260260
| | unexpected argument of type `{integer}`
261261
| | help: remove the extra argument
@@ -268,6 +268,81 @@ LL | fn empty() {}
268268
| ^^^^^
269269
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
270270

271-
error: aborting due to 16 previous errors
271+
error[E0061]: this function takes 0 arguments but 2 arguments were supplied
272+
--> $DIR/extra_arguments.rs:14:9
273+
|
274+
LL | empty(1, $y);
275+
| ^^^^^ ----- help: remove the extra argument
276+
| |
277+
| unexpected argument of type `{integer}`
278+
...
279+
LL | foo!(~, 1);
280+
| ----------
281+
| | |
282+
| | unexpected argument of type `{integer}`
283+
| in this macro invocation
284+
|
285+
note: function defined here
286+
--> $DIR/extra_arguments.rs:1:4
287+
|
288+
LL | fn empty() {}
289+
| ^^^^^
290+
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
291+
292+
error[E0061]: this function takes 0 arguments but 2 arguments were supplied
293+
--> $DIR/extra_arguments.rs:11:9
294+
|
295+
LL | empty($x, $y);
296+
| ^^^^^
297+
...
298+
LL | foo!(1, 1);
299+
| ----------
300+
| | | |
301+
| | | unexpected argument of type `{integer}`
302+
| | unexpected argument of type `{integer}`
303+
| in this macro invocation
304+
|
305+
note: function defined here
306+
--> $DIR/extra_arguments.rs:1:4
307+
|
308+
LL | fn empty() {}
309+
| ^^^^^
310+
= 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+
|
319+
320+
error[E0061]: this function takes 1 argument but 2 arguments were supplied
321+
--> $DIR/extra_arguments.rs:53:3
322+
|
323+
LL | one_arg(1, panic!());
324+
| ^^^^^^^ -------- unexpected argument
325+
|
326+
note: function defined here
327+
--> $DIR/extra_arguments.rs:2:4
328+
|
329+
LL | fn one_arg(_a: i32) {}
330+
| ^^^^^^^ -------
331+
332+
error[E0061]: this function takes 1 argument but 2 arguments were supplied
333+
--> $DIR/extra_arguments.rs:54:3
334+
|
335+
LL | one_arg(panic!(), 1);
336+
| ^^^^^^^ - - unexpected argument of type `{integer}`
337+
| |
338+
| help: remove the extra argument
339+
|
340+
note: function defined here
341+
--> $DIR/extra_arguments.rs:2:4
342+
|
343+
LL | fn one_arg(_a: i32) {}
344+
| ^^^^^^^ -------
345+
346+
error: aborting due to 20 previous errors
272347

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

0 commit comments

Comments
 (0)