diff options
Diffstat (limited to 'src/test/ui/argument-suggestions')
23 files changed, 498 insertions, 76 deletions
diff --git a/src/test/ui/argument-suggestions/basic.stderr b/src/test/ui/argument-suggestions/basic.stderr index c495ad6b8..b118ce1bd 100644 --- a/src/test/ui/argument-suggestions/basic.stderr +++ b/src/test/ui/argument-suggestions/basic.stderr @@ -26,7 +26,7 @@ LL | fn extra() {} help: remove the extra argument | LL | extra(); - | ~~~~~~~ + | ~~ error[E0061]: this function takes 1 argument but 0 arguments were supplied --> $DIR/basic.rs:22:5 @@ -42,7 +42,7 @@ LL | fn missing(_i: u32) {} help: provide the argument | LL | missing(/* u32 */); - | ~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:23:5 @@ -60,7 +60,7 @@ LL | fn swapped(_i: u32, _s: &str) {} help: swap these arguments | LL | swapped(1, ""); - | ~~~~~~~~~~~~~~ + | ~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:24:5 @@ -79,7 +79,7 @@ LL | fn permuted(_x: X, _y: Y, _z: Z) {} help: reorder these arguments | LL | permuted(X {}, Y {}, Z {}); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error[E0057]: this function takes 1 argument but 0 arguments were supplied --> $DIR/basic.rs:27:5 @@ -95,7 +95,7 @@ LL | let closure = |x| x; help: provide the argument | LL | closure(/* value */); - | ~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~ error: aborting due to 6 previous errors diff --git a/src/test/ui/argument-suggestions/complex.stderr b/src/test/ui/argument-suggestions/complex.stderr index fa030a8f4..205a85298 100644 --- a/src/test/ui/argument-suggestions/complex.stderr +++ b/src/test/ui/argument-suggestions/complex.stderr @@ -8,11 +8,11 @@ note: function defined here --> $DIR/complex.rs:11:4 | LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} - | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------ + | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ----- help: did you mean | LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {}); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/exotic-calls.stderr b/src/test/ui/argument-suggestions/exotic-calls.stderr index ca93ecc4e..0580e53c5 100644 --- a/src/test/ui/argument-suggestions/exotic-calls.stderr +++ b/src/test/ui/argument-suggestions/exotic-calls.stderr @@ -12,7 +12,7 @@ LL | fn foo<T: Fn()>(t: T) { help: remove the extra argument | LL | t(); - | ~~~ + | ~~ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:7:5 @@ -28,7 +28,7 @@ LL | fn bar(t: impl Fn()) { help: remove the extra argument | LL | t(); - | ~~~ + | ~~ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:16:5 @@ -44,7 +44,7 @@ LL | fn baz() -> impl Fn() { help: remove the extra argument | LL | baz()() - | + | ~~ error[E0057]: this function takes 0 arguments but 1 argument was supplied --> $DIR/exotic-calls.rs:22:5 @@ -60,7 +60,7 @@ LL | let x = || {}; help: remove the extra argument | LL | x(); - | ~~~ + | ~~ error: aborting due to 4 previous errors diff --git a/src/test/ui/argument-suggestions/extra_arguments.stderr b/src/test/ui/argument-suggestions/extra_arguments.stderr index 32b1e1573..48787b0c3 100644 --- a/src/test/ui/argument-suggestions/extra_arguments.stderr +++ b/src/test/ui/argument-suggestions/extra_arguments.stderr @@ -12,7 +12,7 @@ LL | fn empty() {} help: remove the extra argument | LL | empty(); - | ~~~~~~~ + | ~~ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/extra_arguments.rs:9:3 @@ -28,7 +28,7 @@ LL | fn one_arg(_a: i32) {} help: remove the extra argument | LL | one_arg(1); - | ~~~~~~~~~~ + | ~~~ error[E0061]: this function takes 1 argument but 2 arguments were supplied --> $DIR/extra_arguments.rs:10:3 @@ -44,7 +44,7 @@ LL | fn one_arg(_a: i32) {} help: remove the extra argument | LL | one_arg(1); - | ~~~~~~~~~~ + | ~~~ error[E0061]: this function takes 1 argument but 3 arguments were supplied --> $DIR/extra_arguments.rs:11:3 @@ -62,7 +62,7 @@ LL | fn one_arg(_a: i32) {} help: remove the extra arguments | LL | one_arg(1); - | ~~~~~~~~~~ + | ~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:13:3 @@ -78,7 +78,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} help: remove the extra argument | LL | two_arg_same(1, 1); - | ~~~~~~~~~~~~~~~~~~ + | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:14:3 @@ -94,7 +94,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} help: remove the extra argument | LL | two_arg_same(1, 1); - | ~~~~~~~~~~~~~~~~~~ + | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:16:3 @@ -110,7 +110,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove the extra argument | LL | two_arg_diff(1, ""); - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:17:3 @@ -126,7 +126,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove the extra argument | LL | two_arg_diff(1, ""); - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~ error[E0061]: this function takes 2 arguments but 4 arguments were supplied --> $DIR/extra_arguments.rs:18:3 @@ -144,7 +144,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove the extra arguments | LL | two_arg_diff(1, ""); - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~ error[E0061]: this function takes 2 arguments but 4 arguments were supplied --> $DIR/extra_arguments.rs:19:3 @@ -162,7 +162,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove the extra arguments | LL | two_arg_diff(1, ""); - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:22:3 @@ -178,7 +178,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} help: remove the extra argument | LL | two_arg_same(1, 1); - | ~~~~~~~~~~~~~~~~~~ + | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:23:3 @@ -194,7 +194,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove the extra argument | LL | two_arg_diff(1, ""); - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:24:3 @@ -213,7 +213,7 @@ LL | fn two_arg_same(_a: i32, _b: i32) {} help: remove the extra argument | LL | two_arg_same(1, 1); - | ~~~~~~~~~~~~~~~~~~ + | ~~~~~~ error[E0061]: this function takes 2 arguments but 3 arguments were supplied --> $DIR/extra_arguments.rs:30:3 @@ -232,7 +232,7 @@ LL | fn two_arg_diff(_a: i32, _b: &str) {} help: remove the extra argument | LL | two_arg_diff(1, ""); - | ~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~ error: aborting due to 14 previous errors diff --git a/src/test/ui/argument-suggestions/invalid_arguments.stderr b/src/test/ui/argument-suggestions/invalid_arguments.stderr index 33f27d48f..303f08695 100644 --- a/src/test/ui/argument-suggestions/invalid_arguments.stderr +++ b/src/test/ui/argument-suggestions/invalid_arguments.stderr @@ -24,7 +24,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ ------- error[E0308]: mismatched types --> $DIR/invalid_arguments.rs:17:16 @@ -38,7 +38,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:6:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ ------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:18:3 @@ -66,7 +66,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ ------- error[E0308]: mismatched types --> $DIR/invalid_arguments.rs:20:16 @@ -80,7 +80,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:7:4 | LL | fn two_arg_diff(_a: i32, _b: f32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ ------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:21:3 @@ -108,7 +108,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^ ------- error[E0308]: mismatched types --> $DIR/invalid_arguments.rs:25:21 @@ -122,7 +122,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^ ------- error[E0308]: mismatched types --> $DIR/invalid_arguments.rs:26:26 @@ -136,7 +136,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^ -------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:28:3 @@ -207,7 +207,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} - | ^^^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^^^ ------- error[E0308]: mismatched types --> $DIR/invalid_arguments.rs:35:23 @@ -221,7 +221,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} - | ^^^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^^^ ------- error[E0308]: mismatched types --> $DIR/invalid_arguments.rs:36:26 @@ -235,7 +235,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} - | ^^^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^^^ -------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:38:3 diff --git a/src/test/ui/argument-suggestions/issue-100478.rs b/src/test/ui/argument-suggestions/issue-100478.rs new file mode 100644 index 000000000..6bef6ad10 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-100478.rs @@ -0,0 +1,52 @@ +use std::sync::Arc; +macro_rules! GenT { + ($name:tt) => { + #[derive(Default, Debug)] + struct $name { + #[allow(unused)] + val: i32, + } + + impl $name { + #[allow(unused)] + fn new(val: i32) -> Self { + $name { val } + } + } + }; +} + +GenT!(T1); +GenT!(T2); +GenT!(T3); +GenT!(T4); +GenT!(T5); +GenT!(T6); +GenT!(T7); +GenT!(T8); + +#[allow(unused)] +fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {} +fn three_diff(_a: T1, _b: T2, _c: T3) {} +fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} + +fn main() { + three_diff(T2::new(0)); //~ ERROR this function takes + four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308] + four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308] + + let p1 = T1::new(0); + let p2 = Arc::new(T2::new(0)); + let p3 = T3::new(0); + let p4 = Arc::new(T4::new(1)); + let p5 = T5::new(0); + let p6 = T6::new(0); + let p7 = T7::new(0); + let p8 = Arc::default(); + + foo( + //~^ 47:5: 47:8: this function takes 8 arguments but 7 arguments were supplied [E0061] + p1, //p2, + p3, p4, p5, p6, p7, p8, + ); +} diff --git a/src/test/ui/argument-suggestions/issue-100478.stderr b/src/test/ui/argument-suggestions/issue-100478.stderr new file mode 100644 index 000000000..df02a312c --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-100478.stderr @@ -0,0 +1,81 @@ +error[E0061]: this function takes 3 arguments but 1 argument was supplied + --> $DIR/issue-100478.rs:34:5 + | +LL | three_diff(T2::new(0)); + | ^^^^^^^^^^------------ + | || + | |an argument of type `T1` is missing + | an argument of type `T3` is missing + | +note: function defined here + --> $DIR/issue-100478.rs:30:4 + | +LL | fn three_diff(_a: T1, _b: T2, _c: T3) {} + | ^^^^^^^^^^ ------ ------ ------ +help: provide the arguments + | +LL | three_diff(/* T1 */, T2::new(0), /* T3 */); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-100478.rs:35:5 + | +LL | four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); + | ^^^^^^^^^^^^ ------------- ------------- ------------- ------------- expected `T4`, found `T2` + | | | | + | | | expected `T3`, found `T1` + | | expected `T2`, found `T4` + | expected `T1`, found `T3` + | +note: function defined here + --> $DIR/issue-100478.rs:31:4 + | +LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} + | ^^^^^^^^^^^^ ------ ------ ------ ------ +help: did you mean + | +LL | four_shuffle(T1::default(), T2::default(), T3::default(), T4::default()); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-100478.rs:36:5 + | +LL | four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); + | ^^^^^^^^^^^^ ------------- ------------- ------------- expected struct `T4`, found struct `T3` + | | | + | | expected `T3`, found `T1` + | expected `T1`, found `T3` + | +note: function defined here + --> $DIR/issue-100478.rs:31:4 + | +LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} + | ^^^^^^^^^^^^ ------ ------ ------ ------ +help: swap these arguments + | +LL | four_shuffle(T1::default(), T2::default(), T3::default(), /* T4 */); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0061]: this function takes 8 arguments but 7 arguments were supplied + --> $DIR/issue-100478.rs:47:5 + | +LL | foo( + | ^^^ +... +LL | p3, p4, p5, p6, p7, p8, + | -- an argument of type `Arc<T2>` is missing + | +note: function defined here + --> $DIR/issue-100478.rs:29:4 + | +LL | fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {} + | ^^^ ------ ----------- ------ ----------- ------ ------ ------ ----------- +help: provide the argument + | +LL | foo(p1, /* Arc<T2> */, p3, p4, p5, p6, p7, p8); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0061, E0308. +For more information about an error, try `rustc --explain E0061`. diff --git a/src/test/ui/argument-suggestions/issue-101097.rs b/src/test/ui/argument-suggestions/issue-101097.rs new file mode 100644 index 000000000..7994d3cd9 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-101097.rs @@ -0,0 +1,21 @@ +struct A; +struct B; +struct C; +struct D; + +fn f( + a1: A, + a2: A, + b1: B, + b2: B, + c1: C, + c2: C, +) {} + +fn main() { + f(C, A, A, A, B, B, C); //~ ERROR this function takes 6 arguments but 7 arguments were supplied [E0061] + f(C, C, A, A, B, B); //~ ERROR arguments to this function are incorrect [E0308] + f(A, A, D, D, B, B); //~ arguments to this function are incorrect [E0308] + f(C, C, B, B, A, A); //~ arguments to this function are incorrect [E0308] + f(C, C, A, B, A, A); //~ arguments to this function are incorrect [E0308] +} diff --git a/src/test/ui/argument-suggestions/issue-101097.stderr b/src/test/ui/argument-suggestions/issue-101097.stderr new file mode 100644 index 000000000..096f8c226 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-101097.stderr @@ -0,0 +1,160 @@ +error[E0061]: this function takes 6 arguments but 7 arguments were supplied + --> $DIR/issue-101097.rs:16:5 + | +LL | f(C, A, A, A, B, B, C); + | ^ - - - - expected `C`, found `B` + | | | | + | | | argument of type `A` unexpected + | | expected `B`, found `A` + | expected `A`, found `C` + | +note: function defined here + --> $DIR/issue-101097.rs:6:4 + | +LL | fn f( + | ^ +LL | a1: A, + | ----- +LL | a2: A, + | ----- +LL | b1: B, + | ----- +LL | b2: B, + | ----- +LL | c1: C, + | ----- +LL | c2: C, + | ----- +help: did you mean + | +LL | f(A, A, B, B, C, C); + | ~~~~~~~~~~~~~~~~~~ + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-101097.rs:17:5 + | +LL | f(C, C, A, A, B, B); + | ^ + | +note: function defined here + --> $DIR/issue-101097.rs:6:4 + | +LL | fn f( + | ^ +LL | a1: A, + | ----- +LL | a2: A, + | ----- +LL | b1: B, + | ----- +LL | b2: B, + | ----- +LL | c1: C, + | ----- +LL | c2: C, + | ----- +help: did you mean + | +LL | f(A, A, B, B, C, C); + | ~~~~~~~~~~~~~~~~~~ + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-101097.rs:18:5 + | +LL | f(A, A, D, D, B, B); + | ^ - - ---- two arguments of type `C` and `C` are missing + | | | + | | argument of type `D` unexpected + | argument of type `D` unexpected + | +note: function defined here + --> $DIR/issue-101097.rs:6:4 + | +LL | fn f( + | ^ +LL | a1: A, + | ----- +LL | a2: A, + | ----- +LL | b1: B, + | ----- +LL | b2: B, + | ----- +LL | c1: C, + | ----- +LL | c2: C, + | ----- +help: did you mean + | +LL | f(A, A, B, B, /* C */, /* C */); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-101097.rs:19:5 + | +LL | f(C, C, B, B, A, A); + | ^ - - - - expected `C`, found `A` + | | | | + | | | expected `C`, found `A` + | | expected `A`, found `C` + | expected `A`, found `C` + | +note: function defined here + --> $DIR/issue-101097.rs:6:4 + | +LL | fn f( + | ^ +LL | a1: A, + | ----- +LL | a2: A, + | ----- +LL | b1: B, + | ----- +LL | b2: B, + | ----- +LL | c1: C, + | ----- +LL | c2: C, + | ----- +help: did you mean + | +LL | f(A, A, B, B, C, C); + | ~~~~~~~~~~~~~~~~~~ + +error[E0308]: arguments to this function are incorrect + --> $DIR/issue-101097.rs:20:5 + | +LL | f(C, C, A, B, A, A); + | ^ - - - - - expected `C`, found `A` + | | | | | + | | | | expected `C`, found `A` + | | | expected struct `B`, found struct `A` + | | expected `A`, found `C` + | expected `A`, found `C` + | +note: function defined here + --> $DIR/issue-101097.rs:6:4 + | +LL | fn f( + | ^ +LL | a1: A, + | ----- +LL | a2: A, + | ----- +LL | b1: B, + | ----- +LL | b2: B, + | ----- +LL | c1: C, + | ----- +LL | c2: C, + | ----- +help: did you mean + | +LL | f(A, A, /* B */, B, C, C); + | ~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0061, E0308. +For more information about an error, try `rustc --explain E0061`. diff --git a/src/test/ui/argument-suggestions/issue-96638.stderr b/src/test/ui/argument-suggestions/issue-96638.stderr index 8af31b8b7..4d18b97c9 100644 --- a/src/test/ui/argument-suggestions/issue-96638.stderr +++ b/src/test/ui/argument-suggestions/issue-96638.stderr @@ -2,7 +2,9 @@ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/issue-96638.rs:8:5 | LL | f(&x, ""); - | ^ -- an argument of type `usize` is missing + | ^ -- -- expected `usize`, found `&str` + | | + | an argument of type `usize` is missing | note: function defined here --> $DIR/issue-96638.rs:1:4 @@ -12,7 +14,7 @@ LL | fn f(_: usize, _: &usize, _: usize) {} help: provide the argument | LL | f(/* usize */, &x, /* usize */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/issue-97197.stderr b/src/test/ui/argument-suggestions/issue-97197.stderr index ac54adc5e..de221ba1f 100644 --- a/src/test/ui/argument-suggestions/issue-97197.stderr +++ b/src/test/ui/argument-suggestions/issue-97197.stderr @@ -12,7 +12,7 @@ LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} help: provide the arguments | LL | g((), /* bool */, /* bool */, /* bool */, /* bool */, ()); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/issue-97484.stderr b/src/test/ui/argument-suggestions/issue-97484.stderr index 9589e919c..caa50f14b 100644 --- a/src/test/ui/argument-suggestions/issue-97484.stderr +++ b/src/test/ui/argument-suggestions/issue-97484.stderr @@ -2,8 +2,9 @@ error[E0061]: this function takes 4 arguments but 7 arguments were supplied --> $DIR/issue-97484.rs:12:5 | LL | foo(&&A, B, C, D, E, F, G); - | ^^^ - - - argument of type `F` unexpected - | | | + | ^^^ - - - - argument of type `F` unexpected + | | | | + | | | expected `&E`, found struct `E` | | argument of type `C` unexpected | argument of type `B` unexpected | @@ -19,7 +20,7 @@ LL | foo(&&A, B, C, D, &E, F, G); help: remove the extra arguments | LL | foo(&&A, D, /* &E */, G); - | ~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/issue-98894.stderr b/src/test/ui/argument-suggestions/issue-98894.stderr index 0c8b94901..f64a83ab7 100644 --- a/src/test/ui/argument-suggestions/issue-98894.stderr +++ b/src/test/ui/argument-suggestions/issue-98894.stderr @@ -12,7 +12,7 @@ LL | (|_, ()| ())(if true {} else {return;}); help: provide the argument | LL | (|_, ()| ())(if true {} else {return;}, ()); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/issue-98897.stderr b/src/test/ui/argument-suggestions/issue-98897.stderr index 8f0d98d09..f2c47d353 100644 --- a/src/test/ui/argument-suggestions/issue-98897.stderr +++ b/src/test/ui/argument-suggestions/issue-98897.stderr @@ -12,7 +12,7 @@ LL | (|_, ()| ())([return, ()]); help: provide the argument | LL | (|_, ()| ())([return, ()], ()); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/issue-99482.stderr b/src/test/ui/argument-suggestions/issue-99482.stderr index bc005e82a..bcf36e37c 100644 --- a/src/test/ui/argument-suggestions/issue-99482.stderr +++ b/src/test/ui/argument-suggestions/issue-99482.stderr @@ -12,7 +12,7 @@ LL | let f = |_: (), f: fn()| f; help: provide the argument | LL | let _f = f((), main); - | ~~~~~~~~~~~ + | ~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index 2509d22d7..ba9ece040 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -12,7 +12,7 @@ LL | fn one_arg(_a: i32) {} help: provide the argument | LL | one_arg(/* i32 */); - | ~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~ error[E0061]: this function takes 2 arguments but 0 arguments were supplied --> $DIR/missing_arguments.rs:14:3 @@ -28,7 +28,7 @@ LL | fn two_same(_a: i32, _b: i32) {} help: provide the arguments | LL | two_same(/* i32 */, /* i32 */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 2 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:15:3 @@ -44,7 +44,7 @@ LL | fn two_same(_a: i32, _b: i32) {} help: provide the argument | LL | two_same(1, /* i32 */); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~ error[E0061]: this function takes 2 arguments but 0 arguments were supplied --> $DIR/missing_arguments.rs:16:3 @@ -60,7 +60,7 @@ LL | fn two_diff(_a: i32, _b: f32) {} help: provide the arguments | LL | two_diff(/* i32 */, /* f32 */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 2 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:17:3 @@ -76,7 +76,7 @@ LL | fn two_diff(_a: i32, _b: f32) {} help: provide the argument | LL | two_diff(1, /* f32 */); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~ error[E0061]: this function takes 2 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:18:3 @@ -92,7 +92,7 @@ LL | fn two_diff(_a: i32, _b: f32) {} help: provide the argument | LL | two_diff(/* i32 */, 1.0); - | ~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 0 arguments were supplied --> $DIR/missing_arguments.rs:21:3 @@ -108,7 +108,7 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {} help: provide the arguments | LL | three_same(/* i32 */, /* i32 */, /* i32 */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:22:3 @@ -124,7 +124,7 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {} help: provide the arguments | LL | three_same(1, /* i32 */, /* i32 */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:23:3 @@ -140,7 +140,7 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {} help: provide the argument | LL | three_same(1, 1, /* i32 */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:26:3 @@ -156,7 +156,7 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} help: provide the argument | LL | three_diff(/* i32 */, 1.0, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:27:3 @@ -172,7 +172,7 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} help: provide the argument | LL | three_diff(1, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:28:3 @@ -188,7 +188,7 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} help: provide the argument | LL | three_diff(1, 1.0, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:29:3 @@ -204,7 +204,7 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} help: provide the arguments | LL | three_diff(/* i32 */, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:30:3 @@ -223,7 +223,7 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} help: provide the arguments | LL | three_diff(/* i32 */, 1.0, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 1 argument was supplied --> $DIR/missing_arguments.rs:31:3 @@ -239,7 +239,7 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} help: provide the arguments | LL | three_diff(1, /* f32 */, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 4 arguments but 0 arguments were supplied --> $DIR/missing_arguments.rs:34:3 @@ -255,7 +255,7 @@ LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} help: provide the arguments | LL | four_repeated(/* i32 */, /* f32 */, /* f32 */, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 4 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:35:3 @@ -271,7 +271,7 @@ LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} help: provide the arguments | LL | four_repeated(1, /* f32 */, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 5 arguments but 0 arguments were supplied --> $DIR/missing_arguments.rs:38:3 @@ -287,7 +287,7 @@ LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} help: provide the arguments | LL | complex(/* i32 */, /* f32 */, /* i32 */, /* f32 */, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 5 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:39:3 @@ -303,7 +303,7 @@ LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} help: provide the arguments | LL | complex(1, /* f32 */, /* i32 */, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 19 previous errors diff --git a/src/test/ui/argument-suggestions/mixed_cases.stderr b/src/test/ui/argument-suggestions/mixed_cases.stderr index a52a30d78..8c525db1a 100644 --- a/src/test/ui/argument-suggestions/mixed_cases.stderr +++ b/src/test/ui/argument-suggestions/mixed_cases.stderr @@ -14,7 +14,7 @@ LL | fn two_args(_a: i32, _b: f32) {} help: remove the extra argument | LL | two_args(1, /* f32 */); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 4 arguments were supplied --> $DIR/mixed_cases.rs:11:3 @@ -33,7 +33,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: did you mean | LL | three_args(1, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/mixed_cases.rs:14:3 @@ -52,7 +52,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: provide the argument | LL | three_args(1, /* f32 */, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:17:3 @@ -70,7 +70,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: did you mean | LL | three_args(1, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/mixed_cases.rs:20:3 @@ -89,7 +89,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: swap these arguments | LL | three_args(1, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> $DIR/mixed_cases.rs:23:3 @@ -109,7 +109,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: did you mean | LL | three_args(1, /* f32 */, ""); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error: aborting due to 6 previous errors diff --git a/src/test/ui/argument-suggestions/permuted_arguments.stderr b/src/test/ui/argument-suggestions/permuted_arguments.stderr index f16d22860..655807a7f 100644 --- a/src/test/ui/argument-suggestions/permuted_arguments.stderr +++ b/src/test/ui/argument-suggestions/permuted_arguments.stderr @@ -15,7 +15,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: reorder these arguments | LL | three_args(1, 1.0, ""); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/permuted_arguments.rs:12:3 @@ -36,7 +36,7 @@ LL | fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} help: reorder these arguments | LL | many_args(1, 1.0, "", X {}, Y {}); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/argument-suggestions/swapped_arguments.stderr b/src/test/ui/argument-suggestions/swapped_arguments.stderr index a90792d0c..dabf5e952 100644 --- a/src/test/ui/argument-suggestions/swapped_arguments.stderr +++ b/src/test/ui/argument-suggestions/swapped_arguments.stderr @@ -14,7 +14,7 @@ LL | fn two_args(_a: i32, _b: f32) {} help: swap these arguments | LL | two_args(1, 1.0); - | ~~~~~~~~~~~~~~~~ + | ~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:9:3 @@ -32,7 +32,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: swap these arguments | LL | three_args(1, 1.0, ""); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:10:3 @@ -50,7 +50,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: swap these arguments | LL | three_args(1, 1.0, ""); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:11:3 @@ -68,7 +68,7 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {} help: swap these arguments | LL | three_args(1, 1.0, ""); - | ~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/swapped_arguments.rs:13:3 @@ -88,7 +88,7 @@ LL | fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} help: did you mean | LL | four_args(1, 1.0, "", X {}); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~~~~~~~ error: aborting due to 5 previous errors diff --git a/src/test/ui/argument-suggestions/too-long.rs b/src/test/ui/argument-suggestions/too-long.rs new file mode 100644 index 000000000..7ec56afae --- /dev/null +++ b/src/test/ui/argument-suggestions/too-long.rs @@ -0,0 +1,41 @@ +struct Qux; + +impl Qux { + fn foo( + &self, + a: i32, + b: i32, + c: i32, + d: i32, + e: i32, + f: i32, + g: i32, + h: i32, + i: i32, + j: i32, + k: i32, + l: i32, + ) { + } +} + +fn what( + qux: &Qux, + a: i32, + b: i32, + c: i32, + d: i32, + e: i32, + f: &i32, + g: i32, + h: i32, + i: i32, + j: i32, + k: i32, + l: i32, +) { + qux.foo(a, b, c, d, e, f, g, h, i, j, k, l); + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/argument-suggestions/too-long.stderr b/src/test/ui/argument-suggestions/too-long.stderr new file mode 100644 index 000000000..bd430194c --- /dev/null +++ b/src/test/ui/argument-suggestions/too-long.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/too-long.rs:37:28 + | +LL | qux.foo(a, b, c, d, e, f, g, h, i, j, k, l); + | --- ^ expected `i32`, found `&i32` + | | + | arguments to this function are incorrect + | +note: associated function defined here + --> $DIR/too-long.rs:4:8 + | +LL | fn foo( + | ^^^ +... +LL | f: i32, + | ------ +help: consider dereferencing the borrow + | +LL | qux.foo(a, b, c, d, e, *f, g, h, i, j, k, l); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/argument-suggestions/two-mismatch-notes.rs b/src/test/ui/argument-suggestions/two-mismatch-notes.rs new file mode 100644 index 000000000..1309041ab --- /dev/null +++ b/src/test/ui/argument-suggestions/two-mismatch-notes.rs @@ -0,0 +1,11 @@ +#[derive(Copy, Clone)] +struct Wrapper<T>(T); + +fn foo(_: fn(i32), _: Wrapper<i32>) {} + +fn f(_: u32) {} + +fn main() { + let w = Wrapper::<isize>(1isize); + foo(f, w); //~ ERROR arguments to this function are incorrect +} diff --git a/src/test/ui/argument-suggestions/two-mismatch-notes.stderr b/src/test/ui/argument-suggestions/two-mismatch-notes.stderr new file mode 100644 index 000000000..7873cf964 --- /dev/null +++ b/src/test/ui/argument-suggestions/two-mismatch-notes.stderr @@ -0,0 +1,29 @@ +error[E0308]: arguments to this function are incorrect + --> $DIR/two-mismatch-notes.rs:10:5 + | +LL | foo(f, w); + | ^^^ + | +note: expected `i32`, found `u32` + --> $DIR/two-mismatch-notes.rs:10:9 + | +LL | foo(f, w); + | ^ + = note: expected fn pointer `fn(i32)` + found fn item `fn(u32) {f}` +note: expected `i32`, found `isize` + --> $DIR/two-mismatch-notes.rs:10:12 + | +LL | foo(f, w); + | ^ + = note: expected struct `Wrapper<i32>` + found struct `Wrapper<isize>` +note: function defined here + --> $DIR/two-mismatch-notes.rs:4:4 + | +LL | fn foo(_: fn(i32), _: Wrapper<i32>) {} + | ^^^ ---------- --------------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |