Skip to content

Commit 2e754eb

Browse files
committed
added test case
1 parent 7345449 commit 2e754eb

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

tests/ui/not-enough-arguments.rs

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ macro_rules! delegate_local {
2626
};
2727
}
2828

29+
macro_rules! delegate_from {
30+
($from:ident, $method:ident) => {
31+
<$from>::$method(8)
32+
//~^ ERROR function takes 2 arguments but 1
33+
};
34+
}
35+
2936
struct Bar;
3037

3138
impl Bar {
@@ -34,6 +41,7 @@ impl Bar {
3441
delegate_local!(foo);
3542
delegate!(foo);
3643
//~^ ERROR function takes 2 arguments but 1
44+
delegate_from!(Bar, foo);
3745
}
3846
}
3947

tests/ui/not-enough-arguments.stderr

+26-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | delegate_local!(foo);
88
| -------------------- in this macro invocation
99
|
1010
note: associated function defined here
11-
--> $DIR/not-enough-arguments.rs:32:8
11+
--> $DIR/not-enough-arguments.rs:39:8
1212
|
1313
LL | fn foo(a: u8, b: u8) {}
1414
| ^^^ -----
@@ -19,20 +19,40 @@ LL | <Self>::$method(8, /* u8 */)
1919
| ++++++++++
2020

2121
error[E0061]: this function takes 2 arguments but 1 argument was supplied
22-
--> $DIR/not-enough-arguments.rs:35:9
22+
--> $DIR/not-enough-arguments.rs:42:9
2323
|
2424
LL | delegate!(foo);
2525
| ^^^^^^^^^^^^^^ argument #2 of type `u8` is missing
2626
|
2727
note: associated function defined here
28-
--> $DIR/not-enough-arguments.rs:32:8
28+
--> $DIR/not-enough-arguments.rs:39:8
2929
|
3030
LL | fn foo(a: u8, b: u8) {}
3131
| ^^^ -----
3232
= note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info)
3333

34+
error[E0061]: this function takes 2 arguments but 1 argument was supplied
35+
--> $DIR/not-enough-arguments.rs:31:9
36+
|
37+
LL | <$from>::$method(8)
38+
| ^^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
39+
...
40+
LL | delegate_from!(Bar, foo);
41+
| ------------------------ in this macro invocation
42+
|
43+
note: associated function defined here
44+
--> $DIR/not-enough-arguments.rs:39:8
45+
|
46+
LL | fn foo(a: u8, b: u8) {}
47+
| ^^^ -----
48+
= note: this error originates in the macro `delegate_from` (in Nightly builds, run with -Z macro-backtrace for more info)
49+
help: provide the argument
50+
|
51+
LL | <$from>::$method(8, /* u8 */)
52+
| ++++++++++
53+
3454
error[E0061]: this function takes 4 arguments but 3 arguments were supplied
35-
--> $DIR/not-enough-arguments.rs:41:5
55+
--> $DIR/not-enough-arguments.rs:49:5
3656
|
3757
LL | foo(1, 2, 3);
3858
| ^^^--------- argument #4 of type `isize` is missing
@@ -48,7 +68,7 @@ LL | foo(1, 2, 3, /* isize */);
4868
| +++++++++++++
4969

5070
error[E0061]: this function takes 6 arguments but 3 arguments were supplied
51-
--> $DIR/not-enough-arguments.rs:43:5
71+
--> $DIR/not-enough-arguments.rs:51:5
5272
|
5373
LL | bar(1, 2, 3);
5474
| ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
@@ -63,6 +83,6 @@ help: provide the arguments
6383
LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */);
6484
| +++++++++++++++++++++++++++++++++
6585

66-
error: aborting due to 4 previous errors
86+
error: aborting due to 5 previous errors
6787

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

0 commit comments

Comments
 (0)