Skip to content

Commit 91255f7

Browse files
committed
not-enough-arguments
1 parent ad754e9 commit 91255f7

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
//! Ensure clean diagnostics for argument count mismatches without unrelated errors.
2+
//!
3+
//! `delegate!` part related: <https://github.com/rust-lang/rust/pull/140591>
4+
15
//@ aux-build: delegate_macro.rs
26
extern crate delegate_macro;
37
use delegate_macro::delegate;
48

5-
// Check that the only error msg we report is the
6-
// mismatch between the # of params, and not other
7-
// unrelated errors.
89
fn foo(a: isize, b: isize, c: isize, d: isize) {
910
panic!();
1011
}
1112

12-
// Check that all arguments are shown in the error message, even if they're across multiple lines.
1313
fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
1414
println!("{}", a);
1515
println!("{}", b);
@@ -37,6 +37,7 @@ struct Bar;
3737

3838
impl Bar {
3939
fn foo(a: u8, b: u8) {}
40+
4041
fn bar() {
4142
delegate_local!(foo);
4243
delegate!(foo);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0061]: this function takes 2 arguments but 1 argument was supplied
2-
--> $DIR/not-enough-arguments.rs:24:9
2+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:24:9
33
|
44
LL | <Self>::$method(8)
55
| ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
@@ -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:39:8
11+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8
1212
|
1313
LL | fn foo(a: u8, b: u8) {}
1414
| ^^^ -----
@@ -19,20 +19,20 @@ 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:42:9
22+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:43: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:39:8
28+
--> $DIR/fn-arg-count-mismatch-diagnostics.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

3434
error[E0061]: this function takes 2 arguments but 1 argument was supplied
35-
--> $DIR/not-enough-arguments.rs:31:9
35+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:31:9
3636
|
3737
LL | <$from>::$method(8)
3838
| ^^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
@@ -41,7 +41,7 @@ LL | delegate_from!(Bar, foo);
4141
| ------------------------ in this macro invocation
4242
|
4343
note: associated function defined here
44-
--> $DIR/not-enough-arguments.rs:39:8
44+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8
4545
|
4646
LL | fn foo(a: u8, b: u8) {}
4747
| ^^^ -----
@@ -52,13 +52,13 @@ LL | <$from>::$method(8, /* u8 */)
5252
| ++++++++++
5353

5454
error[E0061]: this function takes 4 arguments but 3 arguments were supplied
55-
--> $DIR/not-enough-arguments.rs:49:5
55+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:50:5
5656
|
5757
LL | foo(1, 2, 3);
5858
| ^^^--------- argument #4 of type `isize` is missing
5959
|
6060
note: function defined here
61-
--> $DIR/not-enough-arguments.rs:8:4
61+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:9:4
6262
|
6363
LL | fn foo(a: isize, b: isize, c: isize, d: isize) {
6464
| ^^^ --------
@@ -68,13 +68,13 @@ LL | foo(1, 2, 3, /* isize */);
6868
| +++++++++++++
6969

7070
error[E0061]: this function takes 6 arguments but 3 arguments were supplied
71-
--> $DIR/not-enough-arguments.rs:51:5
71+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5
7272
|
7373
LL | bar(1, 2, 3);
7474
| ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
7575
|
7676
note: function defined here
77-
--> $DIR/not-enough-arguments.rs:13:4
77+
--> $DIR/fn-arg-count-mismatch-diagnostics.rs:13:4
7878
|
7979
LL | fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
8080
| ^^^ ------ ------ ------

0 commit comments

Comments
 (0)