1
Fork 0

Tweak wording of fn call with wrong number of args

This commit is contained in:
Esteban Küber 2023-01-05 03:02:10 +00:00
parent b7cdb635c4
commit 5393c6bbd1
64 changed files with 143 additions and 146 deletions

View file

@ -473,7 +473,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_expr: &hir::Expr<'tcx>, call_expr: &hir::Expr<'tcx>,
) { ) {
// Next, let's construct the error // Next, let's construct the error
let (error_span, full_call_span, ctor_of, is_method) = match &call_expr.kind { let (error_span, full_call_span, call_name, is_method) = match &call_expr.kind {
hir::ExprKind::Call( hir::ExprKind::Call(
hir::Expr { hir_id, span, kind: hir::ExprKind::Path(qpath), .. }, hir::Expr { hir_id, span, kind: hir::ExprKind::Path(qpath), .. },
_, _,
@ -481,12 +481,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Res::Def(DefKind::Ctor(of, _), _) = if let Res::Def(DefKind::Ctor(of, _), _) =
self.typeck_results.borrow().qpath_res(qpath, *hir_id) self.typeck_results.borrow().qpath_res(qpath, *hir_id)
{ {
(call_span, *span, Some(of), false) let name = match of {
CtorOf::Struct => "struct",
CtorOf::Variant => "enum variant",
};
(call_span, *span, name, false)
} else { } else {
(call_span, *span, None, false) (call_span, *span, "function", false)
} }
} }
hir::ExprKind::Call(hir::Expr { span, .. }, _) => (call_span, *span, None, false), hir::ExprKind::Call(hir::Expr { span, .. }, _) => (call_span, *span, "function", false),
hir::ExprKind::MethodCall(path_segment, _, _, span) => { hir::ExprKind::MethodCall(path_segment, _, _, span) => {
let ident_span = path_segment.ident.span; let ident_span = path_segment.ident.span;
let ident_span = if let Some(args) = path_segment.args { let ident_span = if let Some(args) = path_segment.args {
@ -494,17 +498,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else { } else {
ident_span ident_span
}; };
// methods are never ctors (*span, ident_span, "method", true)
(*span, ident_span, None, true)
} }
k => span_bug!(call_span, "checking argument types on a non-call: `{:?}`", k), k => span_bug!(call_span, "checking argument types on a non-call: `{:?}`", k),
}; };
let args_span = error_span.trim_start(full_call_span).unwrap_or(error_span); let args_span = error_span.trim_start(full_call_span).unwrap_or(error_span);
let call_name = match ctor_of {
Some(CtorOf::Struct) => "struct",
Some(CtorOf::Variant) => "enum variant",
None => "function",
};
// Don't print if it has error types or is just plain `_` // Don't print if it has error types or is just plain `_`
fn has_error_or_infer<'tcx>(tys: impl IntoIterator<Item = Ty<'tcx>>) -> bool { fn has_error_or_infer<'tcx>(tys: impl IntoIterator<Item = Ty<'tcx>>) -> bool {
@ -690,8 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err = tcx.sess.struct_span_err_with_code( err = tcx.sess.struct_span_err_with_code(
full_call_span, full_call_span,
&format!( &format!(
"this {} takes {}{} but {} {} supplied", "{call_name} takes {}{} but {} {} supplied",
call_name,
if c_variadic { "at least " } else { "" }, if c_variadic { "at least " } else { "" },
potentially_plural_count( potentially_plural_count(
formal_and_expected_inputs.len(), formal_and_expected_inputs.len(),

View file

@ -7,7 +7,7 @@
struct Layout; struct Layout;
#[alloc_error_handler] #[alloc_error_handler]
fn oom() -> ! { //~ ERROR this function takes 0 arguments but 1 argument was supplied fn oom() -> ! { //~ ERROR function takes 0 arguments but 1 argument was supplied
loop {} loop {}
} }

View file

@ -18,11 +18,11 @@ fn permuted(_x: X, _y: Y, _z: Z) {}
fn main() { fn main() {
invalid(1.0); //~ ERROR mismatched types invalid(1.0); //~ ERROR mismatched types
extra(""); //~ ERROR this function takes extra(""); //~ ERROR function takes
missing(); //~ ERROR this function takes missing(); //~ ERROR function takes
swapped("", 1); //~ ERROR arguments to this function are incorrect swapped("", 1); //~ ERROR arguments to this function are incorrect
permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect
let closure = |x| x; let closure = |x| x;
closure(); //~ ERROR this function takes closure(); //~ ERROR function takes
} }

View file

@ -4,5 +4,5 @@ fn foo(x: &(dyn Display + Send)) {}
fn main() { fn main() {
foo(); foo();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied //~^ ERROR function takes 1 argument but 0 arguments were supplied
} }

View file

@ -1,11 +1,11 @@
fn foo<T: Fn()>(t: T) { fn foo<T: Fn()>(t: T) {
t(1i32); t(1i32);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn bar(t: impl Fn()) { fn bar(t: impl Fn()) {
t(1i32); t(1i32);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn baz() -> impl Fn() { fn baz() -> impl Fn() {
@ -14,13 +14,13 @@ fn baz() -> impl Fn() {
fn baz2() { fn baz2() {
baz()(1i32) baz()(1i32)
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn qux() { fn qux() {
let x = || {}; let x = || {};
x(1i32); x(1i32);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn main() {} fn main() {}

View file

@ -5,5 +5,5 @@ extern "Rust" {
fn main() { fn main() {
dstfn(1); dstfn(1);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -4,30 +4,30 @@ fn two_arg_same(_a: i32, _b: i32) {}
fn two_arg_diff(_a: i32, _b: &str) {} fn two_arg_diff(_a: i32, _b: &str) {}
fn main() { fn main() {
empty(""); //~ ERROR this function takes empty(""); //~ ERROR function takes
one_arg(1, 1); //~ ERROR this function takes one_arg(1, 1); //~ ERROR function takes
one_arg(1, ""); //~ ERROR this function takes one_arg(1, ""); //~ ERROR function takes
one_arg(1, "", 1.0); //~ ERROR this function takes one_arg(1, "", 1.0); //~ ERROR function takes
two_arg_same(1, 1, 1); //~ ERROR this function takes two_arg_same(1, 1, 1); //~ ERROR function takes
two_arg_same(1, 1, 1.0); //~ ERROR this function takes two_arg_same(1, 1, 1.0); //~ ERROR function takes
two_arg_diff(1, 1, ""); //~ ERROR this function takes two_arg_diff(1, 1, ""); //~ ERROR function takes
two_arg_diff(1, "", ""); //~ ERROR this function takes two_arg_diff(1, "", ""); //~ ERROR function takes
two_arg_diff(1, 1, "", ""); //~ ERROR this function takes two_arg_diff(1, 1, "", ""); //~ ERROR function takes
two_arg_diff(1, "", 1, ""); //~ ERROR this function takes two_arg_diff(1, "", 1, ""); //~ ERROR function takes
// Check with weird spacing and newlines // Check with weird spacing and newlines
two_arg_same(1, 1, ""); //~ ERROR this function takes two_arg_same(1, 1, ""); //~ ERROR function takes
two_arg_diff(1, 1, ""); //~ ERROR this function takes two_arg_diff(1, 1, ""); //~ ERROR function takes
two_arg_same( //~ ERROR this function takes two_arg_same( //~ ERROR function takes
1, 1,
1, 1,
"" ""
); );
two_arg_diff( //~ ERROR this function takes two_arg_diff( //~ ERROR function takes
1, 1,
1, 1,
"" ""

View file

@ -2,6 +2,6 @@ fn foo(i: impl std::fmt::Display) {}
fn main() { fn main() {
foo::<()>(()); foo::<()>(());
//~^ ERROR this function takes 0 generic arguments but 1 generic argument was supplied //~^ ERROR function takes 0 generic arguments but 1 generic argument was supplied
//~| ERROR `()` doesn't implement `std::fmt::Display` //~| ERROR `()` doesn't implement `std::fmt::Display`
} }

View file

@ -31,7 +31,7 @@ fn three_diff(_a: T1, _b: T2, _c: T3) {}
fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
fn main() { fn main() {
three_diff(T2::new(0)); //~ ERROR this function takes three_diff(T2::new(0)); //~ ERROR 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(), 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] four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308]

View file

@ -13,7 +13,7 @@ fn f(
) {} ) {}
fn main() { fn main() {
f(C, A, A, A, B, B, C); //~ ERROR this function takes 6 arguments but 7 arguments were supplied [E0061] f(C, A, A, A, B, B, C); //~ ERROR 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(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(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, B, B, A, A); //~ arguments to this function are incorrect [E0308]

View file

@ -5,5 +5,5 @@ fn arg<T>() -> T { todo!() }
fn main() { fn main() {
let x = arg(); // `x` must be inferred let x = arg(); // `x` must be inferred
// The reference on `&x` is important to reproduce the ICE // The reference on `&x` is important to reproduce the ICE
f(&x, ""); //~ ERROR this function takes 3 arguments but 2 arguments were supplied f(&x, ""); //~ ERROR function takes 3 arguments but 2 arguments were supplied
} }

View file

@ -1,6 +1,6 @@
fn main() { fn main() {
g((), ()); g((), ());
//~^ ERROR this function takes 6 arguments but 2 arguments were supplied //~^ ERROR function takes 6 arguments but 2 arguments were supplied
} }
pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}

View file

@ -10,5 +10,5 @@ fn foo(a: &A, d: D, e: &E, g: G) {}
fn main() { fn main() {
foo(&&A, B, C, D, E, F, G); foo(&&A, B, C, D, E, F, G);
//~^ ERROR this function takes 4 arguments but 7 arguments were supplied //~^ ERROR function takes 4 arguments but 7 arguments were supplied
} }

View file

@ -1,4 +1,4 @@
fn main() { fn main() {
(|_, ()| ())(if true {} else {return;}); (|_, ()| ())(if true {} else {return;});
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -1,4 +1,4 @@
fn main() { fn main() {
(|_, ()| ())([return, ()]); (|_, ()| ())([return, ()]);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -1,5 +1,5 @@
fn main() { fn main() {
let f = |_: (), f: fn()| f; let f = |_: (), f: fn()| f;
let _f = f(main); let _f = f(main);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -7,34 +7,34 @@ fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {}
fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {}
fn main() { fn main() {
one_arg(); //~ ERROR this function takes one_arg(); //~ ERROR function takes
// The headers here show the types expected, // The headers here show the types expected,
// with formatting to emphasize which arguments are missing // with formatting to emphasize which arguments are missing
/* i32 f32 */ /* i32 f32 */
two_same( ); //~ ERROR this function takes two_same( ); //~ ERROR function takes
two_same( 1 ); //~ ERROR this function takes two_same( 1 ); //~ ERROR function takes
two_diff( ); //~ ERROR this function takes two_diff( ); //~ ERROR function takes
two_diff( 1 ); //~ ERROR this function takes two_diff( 1 ); //~ ERROR function takes
two_diff( 1.0 ); //~ ERROR this function takes two_diff( 1.0 ); //~ ERROR function takes
/* i32 i32 i32 */ /* i32 i32 i32 */
three_same( ); //~ ERROR this function takes three_same( ); //~ ERROR function takes
three_same( 1 ); //~ ERROR this function takes three_same( 1 ); //~ ERROR function takes
three_same( 1, 1 ); //~ ERROR this function takes three_same( 1, 1 ); //~ ERROR function takes
/* i32 f32 &str */ /* i32 f32 &str */
three_diff( 1.0, "" ); //~ ERROR this function takes three_diff( 1.0, "" ); //~ ERROR function takes
three_diff( 1, "" ); //~ ERROR this function takes three_diff( 1, "" ); //~ ERROR function takes
three_diff( 1, 1.0 ); //~ ERROR this function takes three_diff( 1, 1.0 ); //~ ERROR function takes
three_diff( "" ); //~ ERROR this function takes three_diff( "" ); //~ ERROR function takes
three_diff( 1.0 ); //~ ERROR this function takes three_diff( 1.0 ); //~ ERROR function takes
three_diff( 1 ); //~ ERROR this function takes three_diff( 1 ); //~ ERROR function takes
/* i32 f32 f32 &str */ /* i32 f32 f32 &str */
four_repeated( ); //~ ERROR this function takes four_repeated( ); //~ ERROR function takes
four_repeated( 1, "" ); //~ ERROR this function takes four_repeated( 1, "" ); //~ ERROR function takes
/* i32 f32 i32 f32 &str */ /* i32 f32 i32 f32 &str */
complex( ); //~ ERROR this function takes complex( ); //~ ERROR function takes
complex( 1, "" ); //~ ERROR this function takes complex( 1, "" ); //~ ERROR function takes
} }

View file

@ -7,11 +7,11 @@ fn three_args(_a: i32, _b: f32, _c: &str) {}
fn main() { fn main() {
// Extra + Invalid // Extra + Invalid
two_args(1, "", X {}); //~ ERROR this function takes two_args(1, "", X {}); //~ ERROR function takes
three_args(1, "", X {}, ""); //~ ERROR this function takes three_args(1, "", X {}, ""); //~ ERROR function takes
// Missing and Invalid // Missing and Invalid
three_args(1, X {}); //~ ERROR this function takes three_args(1, X {}); //~ ERROR function takes
// Missing and Extra // Missing and Extra
three_args(1, "", X {}); //~ ERROR arguments to this function are incorrect three_args(1, "", X {}); //~ ERROR arguments to this function are incorrect
@ -20,5 +20,5 @@ fn main() {
three_args("", X {}, 1); //~ ERROR arguments to this function are incorrect three_args("", X {}, 1); //~ ERROR arguments to this function are incorrect
// Swapped and missing // Swapped and missing
three_args("", 1); //~ ERROR this function takes three_args("", 1); //~ ERROR function takes
} }

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | qux.foo(a, b, c, d, e, f, g, h, i, j, k, l); LL | qux.foo(a, b, c, d, e, f, g, h, i, j, k, l);
| --- ^ expected `i32`, found `&i32` | --- ^ expected `i32`, found `&i32`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
note: associated function defined here note: associated function defined here
--> $DIR/too-long.rs:4:8 --> $DIR/too-long.rs:4:8

View file

@ -32,7 +32,7 @@ error[E0308]: mismatched types
LL | fn f() { ModelT.chip_paint(Blue); } LL | fn f() { ModelT.chip_paint(Blue); }
| ---------- ^^^^ expected struct `Black`, found struct `Blue` | ---------- ^^^^ expected struct `Black`, found struct `Blue`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
note: associated function defined here note: associated function defined here
--> $DIR/associated-type-projection-from-supertrait.rs:12:8 --> $DIR/associated-type-projection-from-supertrait.rs:12:8
@ -46,7 +46,7 @@ error[E0308]: mismatched types
LL | fn g() { ModelU.chip_paint(Black); } LL | fn g() { ModelU.chip_paint(Black); }
| ---------- ^^^^^ expected struct `Blue`, found struct `Black` | ---------- ^^^^^ expected struct `Blue`, found struct `Black`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
note: associated function defined here note: associated function defined here
--> $DIR/associated-type-projection-from-supertrait.rs:12:8 --> $DIR/associated-type-projection-from-supertrait.rs:12:8

View file

@ -19,8 +19,8 @@ extern "C" fn bar(f: isize, x: u8) {}
fn main() { fn main() {
unsafe { unsafe {
foo(); //~ ERROR this function takes at least 2 arguments but 0 arguments were supplied foo(); //~ ERROR function takes at least 2 arguments but 0 arguments were supplied
foo(1); //~ ERROR this function takes at least 2 arguments but 1 argument was supplied foo(1); //~ ERROR function takes at least 2 arguments but 1 argument was supplied
let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types
let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types

View file

@ -13,5 +13,5 @@ fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
fn main() { fn main() {
test::<2>(); test::<2>();
//~^ ERROR this function takes 2 generic arguments //~^ ERROR function takes 2 generic arguments
} }

View file

@ -4,8 +4,8 @@ fn foo<const X: usize, const Y: usize>() -> usize {
fn main() { fn main() {
foo::<0>(); foo::<0>();
//~^ ERROR this function takes 2 //~^ ERROR function takes 2
foo::<0, 0, 0>(); foo::<0, 0, 0>();
//~^ ERROR this function takes 2 //~^ ERROR function takes 2
} }

View file

@ -1,6 +1,6 @@
fn main() { fn main() {
let needlesArr: Vec<char> = vec!['a', 'f']; let needlesArr: Vec<char> = vec!['a', 'f'];
needlesArr.iter().fold(|x, y| { needlesArr.iter().fold(|x, y| {
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR this method takes 2 arguments but 1 argument was supplied
}); });
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 2 arguments but 1 argument was supplied error[E0061]: this method takes 2 arguments but 1 argument was supplied
--> $DIR/issue-3044.rs:3:23 --> $DIR/issue-3044.rs:3:23
| |
LL | needlesArr.iter().fold(|x, y| { LL | needlesArr.iter().fold(|x, y| {

View file

@ -14,7 +14,7 @@ fn main() {
a = d; a = d;
}; };
Pin::new(&mut b).resume(); Pin::new(&mut b).resume();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied //~^ ERROR this method takes 1 argument but 0 arguments were supplied
// This type error is required to reproduce the ICE... // This type error is required to reproduce the ICE...
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> $DIR/issue-102645.rs:16:22 --> $DIR/issue-102645.rs:16:22
| |
LL | Pin::new(&mut b).resume(); LL | Pin::new(&mut b).resume();

View file

@ -9,5 +9,5 @@ where
{} {}
fn main() { fn main() {
f(&[f()]); //~ ERROR this function takes 1 argument f(&[f()]); //~ ERROR function takes 1 argument
} }

View file

@ -2,5 +2,5 @@ fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
fn main() { fn main() {
f::<[u8]>("a", b"a"); f::<[u8]>("a", b"a");
//~^ ERROR: this function takes 2 generic arguments but 1 generic argument was supplied //~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied
} }

View file

@ -6,7 +6,7 @@ LL | c.read_to(v);
| | | | | |
| | expected `&mut [u8]`, found struct `Vec` | | expected `&mut [u8]`, found struct `Vec`
| | help: consider mutably borrowing here: `&mut v` | | help: consider mutably borrowing here: `&mut v`
| arguments to this function are incorrect | arguments to this method are incorrect
| |
= note: expected mutable reference `&mut [u8]` = note: expected mutable reference `&mut [u8]`
found struct `Vec<_>` found struct `Vec<_>`

View file

@ -8,6 +8,6 @@ fn some_function() {} //~ NOTE defined here
fn main() { fn main() {
some_macro!(some_function); some_macro!(some_function);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
//~| NOTE in this expansion of some_macro! //~| NOTE in this expansion of some_macro!
} }

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | b"".starts_with(stringify!(foo)) LL | b"".starts_with(stringify!(foo))
| ----------- ^^^^^^^^^^^^^^^ expected slice `[u8]`, found `str` | ----------- ^^^^^^^^^^^^^^^ expected slice `[u8]`, found `str`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
= note: expected reference `&[u8]` = note: expected reference `&[u8]`
found reference `&'static str` found reference `&'static str`

View file

@ -3,4 +3,4 @@
fn foo(a: usize) {} fn foo(a: usize) {}
//~^ defined here //~^ defined here
fn main() { foo(5, 6) } fn main() { foo(5, 6) }
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR function takes 1 argument but 2 arguments were supplied

View file

@ -5,7 +5,7 @@ fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next()
fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
//~^ ERROR missing lifetime specifier [E0106] //~^ ERROR missing lifetime specifier [E0106]
//~| ERROR mismatched types //~| ERROR mismatched types
//~| ERROR this function takes 1 argument but 0 arguments were supplied //~| ERROR function takes 1 argument but 0 arguments were supplied
fn parse_type_3() -> &str { unimplemented!() } fn parse_type_3() -> &str { unimplemented!() }
//~^ ERROR missing lifetime specifier [E0106] //~^ ERROR missing lifetime specifier [E0106]

View file

@ -23,7 +23,7 @@ error[E0308]: mismatched types
LL | 1.query::<dyn ToString>("") LL | 1.query::<dyn ToString>("")
| --------------------- ^^ expected trait object `dyn ToString`, found `&str` | --------------------- ^^ expected trait object `dyn ToString`, found `&str`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
= note: expected trait object `dyn ToString` = note: expected trait object `dyn ToString`
found reference `&'static str` found reference `&'static str`

View file

@ -10,13 +10,13 @@ impl Foo {
fn main() { fn main() {
let x = Foo; let x = Foo;
x.zero(0) //~ ERROR this function takes 0 arguments but 1 argument was supplied x.zero(0) //~ ERROR this method takes 0 arguments but 1 argument was supplied
.one() //~ ERROR this function takes 1 argument but 0 arguments were supplied .one() //~ ERROR this method takes 1 argument but 0 arguments were supplied
.two(0); //~ ERROR this function takes 2 arguments but 1 argument was supplied .two(0); //~ ERROR this method takes 2 arguments but 1 argument was supplied
let y = Foo; let y = Foo;
y.zero() y.zero()
.take() //~ ERROR not an iterator .take() //~ ERROR not an iterator
.one(0); .one(0);
y.three::<usize>(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied y.three::<usize>(); //~ ERROR this method takes 3 arguments but 0 arguments were supplied
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 0 arguments but 1 argument was supplied error[E0061]: this method takes 0 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:13:7 --> $DIR/method-call-err-msg.rs:13:7
| |
LL | x.zero(0) LL | x.zero(0)
@ -14,7 +14,7 @@ help: remove the extra argument
LL | x.zero() LL | x.zero()
| ~~ | ~~
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:14:7 --> $DIR/method-call-err-msg.rs:14:7
| |
LL | .one() LL | .one()
@ -30,7 +30,7 @@ help: provide the argument
LL | .one(/* isize */) LL | .one(/* isize */)
| ~~~~~~~~~~~~~ | ~~~~~~~~~~~~~
error[E0061]: this function takes 2 arguments but 1 argument was supplied error[E0061]: this method takes 2 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:15:7 --> $DIR/method-call-err-msg.rs:15:7
| |
LL | .two(0); LL | .two(0);
@ -67,7 +67,7 @@ note: the trait `Iterator` must be implemented
= note: the following trait defines an item `take`, perhaps you need to implement it: = note: the following trait defines an item `take`, perhaps you need to implement it:
candidate #1: `Iterator` candidate #1: `Iterator`
error[E0061]: this function takes 3 arguments but 0 arguments were supplied error[E0061]: this method takes 3 arguments but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:21:7 --> $DIR/method-call-err-msg.rs:21:7
| |
LL | y.three::<usize>(); LL | y.three::<usize>();

View file

@ -33,9 +33,9 @@ fn main() {
let ans = s("what"); let ans = s("what");
//~^ ERROR mismatched types //~^ ERROR mismatched types
let ans = s(); let ans = s();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied //~^ ERROR function takes 1 argument but 0 arguments were supplied
let ans = s("burma", "shave"); let ans = s("burma", "shave");
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR function takes 1 argument but 2 arguments were supplied
F(""); F("");
//~^ ERROR mismatched types //~^ ERROR mismatched types

View file

@ -25,7 +25,7 @@ fn bar(
fn main() { fn main() {
foo(1, 2, 3); foo(1, 2, 3);
//~^ ERROR this function takes 4 arguments but 3 //~^ ERROR function takes 4 arguments but 3
bar(1, 2, 3); bar(1, 2, 3);
//~^ ERROR this function takes 6 arguments but 3 //~^ ERROR function takes 6 arguments but 3
} }

View file

@ -2,7 +2,7 @@ fn main() {
// Make sure primitive type fallback doesn't work in value namespace // Make sure primitive type fallback doesn't work in value namespace
std::mem::size_of(u16); std::mem::size_of(u16);
//~^ ERROR expected value, found builtin type `u16` //~^ ERROR expected value, found builtin type `u16`
//~| ERROR this function takes 0 arguments but 1 argument was supplied //~| ERROR function takes 0 arguments but 1 argument was supplied
// Make sure primitive type fallback doesn't work with global paths // Make sure primitive type fallback doesn't work with global paths
let _: ::u8; let _: ::u8;

View file

@ -4,8 +4,8 @@ fn bar(x, y: usize) {} //~ ERROR expected one of
fn main() { fn main() {
foo(Some(42), 2); foo(Some(42), 2);
foo(Some(42), 2, ""); //~ ERROR this function takes foo(Some(42), 2, ""); //~ ERROR function takes
bar("", ""); //~ ERROR mismatched types bar("", ""); //~ ERROR mismatched types
bar(1, 2); bar(1, 2);
bar(1, 2, 3); //~ ERROR this function takes bar(1, 2, 3); //~ ERROR function takes
} }

View file

@ -9,9 +9,9 @@ impl S {
fn main() { fn main() {
let _: Result<(), String> = Ok(); //~ ERROR this enum variant takes let _: Result<(), String> = Ok(); //~ ERROR this enum variant takes
foo(); //~ ERROR this function takes foo(); //~ ERROR function takes
foo(()); //~ ERROR this function takes foo(()); //~ ERROR function takes
bar(); //~ ERROR this function takes bar(); //~ ERROR function takes
S.baz(); //~ ERROR this function takes S.baz(); //~ ERROR this method takes
S.generic::<()>(); //~ ERROR this function takes S.generic::<()>(); //~ ERROR this method takes
} }

View file

@ -59,7 +59,7 @@ help: provide the argument
LL | bar(()); LL | bar(());
| ~~~~ | ~~~~
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:15:7 --> $DIR/missing-unit-argument.rs:15:7
| |
LL | S.baz(); LL | S.baz();
@ -75,7 +75,7 @@ help: provide the argument
LL | S.baz(()); LL | S.baz(());
| ~~~~ | ~~~~
error[E0061]: this function takes 1 argument but 0 arguments were supplied error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:16:7 --> $DIR/missing-unit-argument.rs:16:7
| |
LL | S.generic::<()>(); LL | S.generic::<()>();

View file

@ -6,7 +6,7 @@ fn main() {
let _: Option<(i32, bool)> = Some(1, 2); let _: Option<(i32, bool)> = Some(1, 2);
//~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied //~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied
int_bool(1, 2); int_bool(1, 2);
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR function takes 1 argument but 2 arguments were supplied
let _: Option<(i8,)> = Some(); let _: Option<(i8,)> = Some();
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied //~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied

View file

@ -5,11 +5,11 @@
fn main() { fn main() {
let _: Result<(i32, i8), ()> = Ok((1, 2)); let _: Result<(i32, i8), ()> = Ok((1, 2));
//~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied //~^ ERROR enum variant takes 1 argument but 2 arguments were supplied
let _: Option<(i32, i8, &'static str)> = Some((1, 2, "hi")); let _: Option<(i32, i8, &'static str)> = Some((1, 2, "hi"));
//~^ ERROR this enum variant takes 1 argument but 3 arguments were supplied //~^ ERROR enum variant takes 1 argument but 3 arguments were supplied
let _: Option<()> = Some(()); let _: Option<()> = Some(());
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied //~^ ERROR enum variant takes 1 argument but 0 arguments were supplied
let _: Option<(i32,)> = Some((3,)); let _: Option<(i32,)> = Some((3,));
//~^ ERROR mismatched types //~^ ERROR mismatched types
@ -17,9 +17,9 @@ fn main() {
let _: Option<(i32,)> = Some((3,)); let _: Option<(i32,)> = Some((3,));
//~^ ERROR mismatched types //~^ ERROR mismatched types
two_ints((1, 2)); //~ ERROR this function takes 1 argument two_ints((1, 2)); //~ ERROR function takes 1 argument
with_generic((3, 4)); //~ ERROR this function takes 1 argument with_generic((3, 4)); //~ ERROR function takes 1 argument
} }
fn two_ints(_: (i32, i32)) { fn two_ints(_: (i32, i32)) {
@ -28,6 +28,6 @@ fn two_ints(_: (i32, i32)) {
fn with_generic<T: Copy + Send>((a, b): (i32, T)) { fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
if false { if false {
// test generics/bound handling // test generics/bound handling
with_generic((a, b)); //~ ERROR this function takes 1 argument with_generic((a, b)); //~ ERROR function takes 1 argument
} }
} }

View file

@ -5,11 +5,11 @@
fn main() { fn main() {
let _: Result<(i32, i8), ()> = Ok(1, 2); let _: Result<(i32, i8), ()> = Ok(1, 2);
//~^ ERROR this enum variant takes 1 argument but 2 arguments were supplied //~^ ERROR enum variant takes 1 argument but 2 arguments were supplied
let _: Option<(i32, i8, &'static str)> = Some(1, 2, "hi"); let _: Option<(i32, i8, &'static str)> = Some(1, 2, "hi");
//~^ ERROR this enum variant takes 1 argument but 3 arguments were supplied //~^ ERROR enum variant takes 1 argument but 3 arguments were supplied
let _: Option<()> = Some(); let _: Option<()> = Some();
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied //~^ ERROR enum variant takes 1 argument but 0 arguments were supplied
let _: Option<(i32,)> = Some(3); let _: Option<(i32,)> = Some(3);
//~^ ERROR mismatched types //~^ ERROR mismatched types
@ -17,9 +17,9 @@ fn main() {
let _: Option<(i32,)> = Some((3)); let _: Option<(i32,)> = Some((3));
//~^ ERROR mismatched types //~^ ERROR mismatched types
two_ints(1, 2); //~ ERROR this function takes 1 argument two_ints(1, 2); //~ ERROR function takes 1 argument
with_generic(3, 4); //~ ERROR this function takes 1 argument with_generic(3, 4); //~ ERROR function takes 1 argument
} }
fn two_ints(_: (i32, i32)) { fn two_ints(_: (i32, i32)) {
@ -28,6 +28,6 @@ fn two_ints(_: (i32, i32)) {
fn with_generic<T: Copy + Send>((a, b): (i32, T)) { fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
if false { if false {
// test generics/bound handling // test generics/bound handling
with_generic(a, b); //~ ERROR this function takes 1 argument with_generic(a, b); //~ ERROR function takes 1 argument
} }
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied error[E0061]: enum variant takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple.rs:7:36 --> $DIR/args-instead-of-tuple.rs:7:36
| |
LL | let _: Result<(i32, i8), ()> = Ok(1, 2); LL | let _: Result<(i32, i8), ()> = Ok(1, 2);
@ -11,7 +11,7 @@ help: wrap these arguments in parentheses to construct a tuple
LL | let _: Result<(i32, i8), ()> = Ok((1, 2)); LL | let _: Result<(i32, i8), ()> = Ok((1, 2));
| + + | + +
error[E0061]: this enum variant takes 1 argument but 3 arguments were supplied error[E0061]: enum variant takes 1 argument but 3 arguments were supplied
--> $DIR/args-instead-of-tuple.rs:9:46 --> $DIR/args-instead-of-tuple.rs:9:46
| |
LL | let _: Option<(i32, i8, &'static str)> = Some(1, 2, "hi"); LL | let _: Option<(i32, i8, &'static str)> = Some(1, 2, "hi");
@ -71,7 +71,7 @@ help: use a trailing comma to create a tuple with one element
LL | let _: Option<(i32,)> = Some((3,)); LL | let _: Option<(i32,)> = Some((3,));
| + | +
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: function takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple.rs:20:5 --> $DIR/args-instead-of-tuple.rs:20:5
| |
LL | two_ints(1, 2); LL | two_ints(1, 2);
@ -87,7 +87,7 @@ help: wrap these arguments in parentheses to construct a tuple
LL | two_ints((1, 2)); LL | two_ints((1, 2));
| + + | + +
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: function takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple.rs:22:5 --> $DIR/args-instead-of-tuple.rs:22:5
| |
LL | with_generic(3, 4); LL | with_generic(3, 4);
@ -103,7 +103,7 @@ help: wrap these arguments in parentheses to construct a tuple
LL | with_generic((3, 4)); LL | with_generic((3, 4));
| + + | + +
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: function takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple.rs:31:9 --> $DIR/args-instead-of-tuple.rs:31:9
| |
LL | with_generic(a, b); LL | with_generic(a, b);

View file

@ -3,6 +3,6 @@
fn two_type_params<A, B>(_: B) {} fn two_type_params<A, B>(_: B) {}
fn main() { fn main() {
two_type_params::<String, _>(100); //~ ERROR this function takes 2 generic arguments two_type_params::<String, _>(100); //~ ERROR function takes 2 generic arguments
two_type_params::<String, _>(100); two_type_params::<String, _>(100);
} }

View file

@ -3,6 +3,6 @@
fn two_type_params<A, B>(_: B) {} fn two_type_params<A, B>(_: B) {}
fn main() { fn main() {
two_type_params::<String>(100); //~ ERROR this function takes 2 generic arguments two_type_params::<String>(100); //~ ERROR function takes 2 generic arguments
two_type_params::<String, _>(100); two_type_params::<String, _>(100);
} }

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap()); LL | let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap());
| --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&str`, found closure | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&str`, found closure
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
= note: expected reference `&str` = note: expected reference `&str`
found closure `[closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28]` found closure `[closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28]`

View file

@ -78,7 +78,7 @@ error[E0308]: mismatched types
LL | x.funk(3); LL | x.funk(3);
| ---- ^ expected associated type, found integer | ---- ^ expected associated type, found integer
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
= note: expected associated type `<T as Trait<i32>>::A` = note: expected associated type `<T as Trait<i32>>::A`
found type `{integer}` found type `{integer}`

View file

@ -7,7 +7,7 @@ LL | impl<F, Name, P> AddClass<Name, F> for Class<P>
LL | builder.push(output); LL | builder.push(output);
| ---- ^^^^^^ expected type parameter `F`, found struct `Class` | ---- ^^^^^^ expected type parameter `F`, found struct `Class`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
= note: expected type parameter `F` = note: expected type parameter `F`
found struct `Class<P>` found struct `Class<P>`

View file

@ -4,7 +4,7 @@ fn bar(s: &str, a: (&str,), s2: &str) {}
fn main() { fn main() {
foo("hi", 1, 2, "hi"); foo("hi", 1, 2, "hi");
//~^ ERROR this function takes 3 arguments but 4 arguments were supplied //~^ ERROR function takes 3 arguments but 4 arguments were supplied
bar("hi", "hi", "hi"); bar("hi", "hi", "hi");
//~^ ERROR mismatched types //~^ ERROR mismatched types
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 3 arguments but 4 arguments were supplied error[E0061]: function takes 3 arguments but 4 arguments were supplied
--> $DIR/add-tuple-within-arguments.rs:6:5 --> $DIR/add-tuple-within-arguments.rs:6:5
| |
LL | foo("hi", 1, 2, "hi"); LL | foo("hi", 1, 2, "hi");

View file

@ -11,7 +11,7 @@ impl Foo {
fn bar() { fn bar() {
let x = Foo; let x = Foo;
test(x.qux(), x.qux()); test(x.qux(), x.qux());
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR function takes 1 argument but 2 arguments were supplied
} }
fn main() {} fn main() {}

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: function takes 1 argument but 2 arguments were supplied
--> $DIR/wrong_argument_ice-2.rs:13:5 --> $DIR/wrong_argument_ice-2.rs:13:5
| |
LL | test(x.qux(), x.qux()); LL | test(x.qux(), x.qux());

View file

@ -7,7 +7,7 @@ fn test(process: &Process, groups: Vec<Group>) -> Vec<Group> {
if groups.capacity() == 0 { if groups.capacity() == 0 {
groups.push(new_group, vec![process]); groups.push(new_group, vec![process]);
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR this method takes 1 argument but 2 arguments were supplied
return groups; return groups;
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: this method takes 1 argument but 2 arguments were supplied
--> $DIR/wrong_argument_ice-3.rs:9:16 --> $DIR/wrong_argument_ice-3.rs:9:16
| |
LL | groups.push(new_group, vec![process]); LL | groups.push(new_group, vec![process]);

View file

@ -1,6 +1,6 @@
fn main() { fn main() {
(|| {})(|| { (|| {})(|| {
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
let b = 1; let b = 1;
}); });
} }

View file

@ -9,7 +9,7 @@ pub struct BuildPlanBuilder {
impl BuildPlanBuilder { impl BuildPlanBuilder {
pub fn or(&mut self) -> &mut Self { pub fn or(&mut self) -> &mut Self {
self.acc.push_back(self.current_provides, self.current_requires); self.acc.push_back(self.current_provides, self.current_requires);
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR method takes 1 argument but 2 arguments were supplied
self self
} }
} }

View file

@ -1,4 +1,4 @@
error[E0061]: this function takes 1 argument but 2 arguments were supplied error[E0061]: method takes 1 argument but 2 arguments were supplied
--> $DIR/wrong_argument_ice.rs:11:18 --> $DIR/wrong_argument_ice.rs:11:18
| |
LL | self.acc.push_back(self.current_provides, self.current_requires); LL | self.acc.push_back(self.current_provides, self.current_requires);

View file

@ -1,4 +1,4 @@
fn main() { fn main() {
let x: Vec::with_capacity(10, 20); //~ ERROR expected type, found `10` let x: Vec::with_capacity(10, 20); //~ ERROR expected type, found `10`
//~^ ERROR this function takes 1 argument //~^ ERROR function takes 1 argument
} }

View file

@ -4,6 +4,6 @@ fn l(_a: Vec<u8>) {}
fn main() { fn main() {
l(vec![]) l(vec![])
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR function takes 1 argument but 2 arguments were supplied
//~| HELP remove the extra argument //~| HELP remove the extra argument
} }

View file

@ -4,6 +4,6 @@ fn l(_a: Vec<u8>) {}
fn main() { fn main() {
l(vec![], vec![]) l(vec![], vec![])
//~^ ERROR this function takes 1 argument but 2 arguments were supplied //~^ ERROR function takes 1 argument but 2 arguments were supplied
//~| HELP remove the extra argument //~| HELP remove the extra argument
} }