Skip to content

Commit bc23701

Browse files
committed
fixed tests
1 parent 9da5ff5 commit bc23701

File tree

3 files changed

+48
-61
lines changed

3 files changed

+48
-61
lines changed

tests/ui/auxiliary/delegate_macro.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[macro_export]
2+
macro_rules! delegate {
3+
($method:ident) => {
4+
<Self>::$method(8)
5+
};
6+
}

tests/ui/not-enough-arguments.rs

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1+
//@ aux-build: delegate_macro.rs
2+
extern crate delegate_macro;
3+
use delegate_macro::delegate;
4+
15
// Check that the only error msg we report is the
26
// mismatch between the # of params, and not other
37
// unrelated errors.
4-
5-
fn foo(a: isize, b: isize, c: isize, d:isize) {
6-
panic!();
8+
fn foo(a: isize, b: isize, c: isize, d: isize) {
9+
panic!();
710
}
811

912
// Check that all arguments are shown in the error message, even if they're across multiple lines.
10-
fn bar(
11-
a: i32,
12-
b: i32,
13-
c: i32,
14-
d: i32,
15-
e: i32,
16-
f: i32,
17-
) {
13+
fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
1814
println!("{}", a);
1915
println!("{}", b);
2016
println!("{}", c);
@@ -23,25 +19,19 @@ fn bar(
2319
println!("{}", f);
2420
}
2521

26-
macro_rules! delegate {
27-
($method:ident) => {
28-
<Self>::$method(8)
29-
//~^ ERROR function takes 2 arguments but 1
30-
};
31-
}
32-
3322
struct Bar;
3423

3524
impl Bar {
36-
fn foo(a: u8, b: u8) {}
37-
fn bar() {
38-
delegate!(foo);
39-
}
25+
fn foo(a: u8, b: u8) {}
26+
fn bar() {
27+
delegate!(foo);
28+
//~^ ERROR function takes 2 arguments but 1
29+
}
4030
}
4131

4232
fn main() {
43-
foo(1, 2, 3);
44-
//~^ ERROR function takes 4 arguments but 3
45-
bar(1, 2, 3);
46-
//~^ ERROR function takes 6 arguments but 3
33+
foo(1, 2, 3);
34+
//~^ ERROR function takes 4 arguments but 3
35+
bar(1, 2, 3);
36+
//~^ ERROR function takes 6 arguments but 3
4737
}

tests/ui/not-enough-arguments.stderr

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,52 @@
11
error[E0061]: this function takes 2 arguments but 1 argument was supplied
2-
--> $DIR/not-enough-arguments.rs:28:7
2+
--> $DIR/not-enough-arguments.rs:27:9
33
|
4-
LL | <Self>::$method(8)
5-
| ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
6-
...
7-
LL | delegate!(foo);
8-
| -------------- in this macro invocation
4+
LL | delegate!(foo);
5+
| ^^^^^^^^^^^^^^ argument #2 of type `u8` is missing
96
|
107
note: associated function defined here
11-
--> $DIR/not-enough-arguments.rs:36:6
8+
--> $DIR/not-enough-arguments.rs:25:8
129
|
13-
LL | fn foo(a: u8, b: u8) {}
14-
| ^^^ -----
10+
LL | fn foo(a: u8, b: u8) {}
11+
| ^^^ -----
1512
= note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info)
1613
help: provide the argument
14+
--> $DIR/auxiliary/delegate_macro.rs:4:26
1715
|
18-
LL | <Self>::$method(8, /* u8 */)
19-
| ++++++++++
16+
LL | <Self>::$method(8, /* u8 */)
17+
| ++++++++++
2018

2119
error[E0061]: this function takes 4 arguments but 3 arguments were supplied
22-
--> $DIR/not-enough-arguments.rs:43:3
20+
--> $DIR/not-enough-arguments.rs:33:5
2321
|
24-
LL | foo(1, 2, 3);
25-
| ^^^--------- argument #4 of type `isize` is missing
22+
LL | foo(1, 2, 3);
23+
| ^^^--------- argument #4 of type `isize` is missing
2624
|
2725
note: function defined here
28-
--> $DIR/not-enough-arguments.rs:5:4
26+
--> $DIR/not-enough-arguments.rs:8:4
2927
|
30-
LL | fn foo(a: isize, b: isize, c: isize, d:isize) {
31-
| ^^^ -------
28+
LL | fn foo(a: isize, b: isize, c: isize, d: isize) {
29+
| ^^^ --------
3230
help: provide the argument
3331
|
34-
LL | foo(1, 2, 3, /* isize */);
35-
| +++++++++++++
32+
LL | foo(1, 2, 3, /* isize */);
33+
| +++++++++++++
3634

3735
error[E0061]: this function takes 6 arguments but 3 arguments were supplied
38-
--> $DIR/not-enough-arguments.rs:45:3
36+
--> $DIR/not-enough-arguments.rs:35:5
3937
|
40-
LL | bar(1, 2, 3);
41-
| ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
38+
LL | bar(1, 2, 3);
39+
| ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
4240
|
4341
note: function defined here
44-
--> $DIR/not-enough-arguments.rs:10:4
45-
|
46-
LL | fn bar(
47-
| ^^^
48-
...
49-
LL | d: i32,
50-
| ------
51-
LL | e: i32,
52-
| ------
53-
LL | f: i32,
54-
| ------
42+
--> $DIR/not-enough-arguments.rs:13:4
43+
|
44+
LL | fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
45+
| ^^^ ------ ------ ------
5546
help: provide the arguments
5647
|
57-
LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */);
58-
| +++++++++++++++++++++++++++++++++
48+
LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */);
49+
| +++++++++++++++++++++++++++++++++
5950

6051
error: aborting due to 3 previous errors
6152

0 commit comments

Comments
 (0)