Skip to content

Commit bdaabc1

Browse files
committed
Add test for "missing function argument" on multiline call
1 parent e1b9081 commit bdaabc1

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,21 @@ impl Bar {
4646
}
4747
}
4848

49+
fn function_with_lots_of_arguments(a: i32, b: char, c: i32, d: i32, e: i32, f: i32) {}
50+
4951
fn main() {
5052
foo(1, 2, 3);
5153
//~^ ERROR function takes 4 arguments but 3
5254
bar(1, 2, 3);
5355
//~^ ERROR function takes 6 arguments but 3
56+
57+
let variable_name = 42;
58+
function_with_lots_of_arguments(
59+
variable_name,
60+
variable_name,
61+
variable_name,
62+
variable_name,
63+
variable_name,
64+
);
65+
//~^^^^^^^ ERROR this function takes 6 arguments but 5 arguments were supplied [E0061]
5466
}

tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ LL | <$from>::$method(8, /* u8 */)
5252
| ++++++++++
5353

5454
error[E0061]: this function takes 4 arguments but 3 arguments were supplied
55-
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:50:5
55+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5
5656
|
5757
LL | foo(1, 2, 3);
5858
| ^^^--------- argument #4 of type `isize` is missing
@@ -68,7 +68,7 @@ LL | foo(1, 2, 3, /* isize */);
6868
| +++++++++++++
6969

7070
error[E0061]: this function takes 6 arguments but 3 arguments were supplied
71-
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5
71+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:54:5
7272
|
7373
LL | bar(1, 2, 3);
7474
| ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
@@ -83,6 +83,32 @@ help: provide the arguments
8383
LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */);
8484
| +++++++++++++++++++++++++++++++++
8585

86-
error: aborting due to 5 previous errors
86+
error[E0061]: this function takes 6 arguments but 5 arguments were supplied
87+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:58:5
88+
|
89+
LL | function_with_lots_of_arguments(
90+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91+
LL | variable_name,
92+
LL | variable_name,
93+
| ------------- argument #2 of type `char` is missing
94+
|
95+
note: function defined here
96+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:49:4
97+
|
98+
LL | fn function_with_lots_of_arguments(a: i32, b: char, c: i32, d: i32, e: i32, f: i32) {}
99+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -------
100+
help: provide the argument
101+
|
102+
LL - function_with_lots_of_arguments(
103+
LL - variable_name,
104+
LL - variable_name,
105+
LL - variable_name,
106+
LL - variable_name,
107+
LL - variable_name,
108+
LL - );
109+
LL + function_with_lots_of_arguments(variable_name, /* char */, variable_name, variable_name, variable_name, variable_name);
110+
|
111+
112+
error: aborting due to 6 previous errors
87113

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

0 commit comments

Comments
 (0)