Rollup merge of #68877 - estebank:point-at-params, r=petrochenkov

On mismatched argument count point at arguments
This commit is contained in:
Mazdak Farrokhzad 2020-02-20 20:18:48 +01:00 committed by GitHub
commit b680a5e7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 214 additions and 105 deletions

View File

@ -3843,17 +3843,58 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
error_code: &str, error_code: &str,
c_variadic: bool, c_variadic: bool,
sugg_unit: bool| { sugg_unit: bool| {
let (span, start_span, args) = match &expr.kind {
hir::ExprKind::Call(hir::Expr { span, .. }, args) => (*span, *span, &args[..]),
hir::ExprKind::MethodCall(path_segment, span, args) => (
*span,
// `sp` doesn't point at the whole `foo.bar()`, only at `bar`.
path_segment
.args
.and_then(|args| args.args.iter().last())
// Account for `foo.bar::<T>()`.
.map(|arg| {
// Skip the closing `>`.
tcx.sess
.source_map()
.next_point(tcx.sess.source_map().next_point(arg.span()))
})
.unwrap_or(*span),
&args[1..], // Skip the receiver.
),
k => span_bug!(sp, "checking argument types on a non-call: `{:?}`", k),
};
let arg_spans = if args.is_empty() {
// foo()
// ^^^-- supplied 0 arguments
// |
// expected 2 arguments
vec![tcx.sess.source_map().next_point(start_span).with_hi(sp.hi())]
} else {
// foo(1, 2, 3)
// ^^^ - - - supplied 3 arguments
// |
// expected 2 arguments
args.iter().map(|arg| arg.span).collect::<Vec<Span>>()
};
let mut err = tcx.sess.struct_span_err_with_code( let mut err = tcx.sess.struct_span_err_with_code(
sp, span,
&format!( &format!(
"this function takes {}{} but {} {} supplied", "this function takes {}{} but {} {} supplied",
if c_variadic { "at least " } else { "" }, if c_variadic { "at least " } else { "" },
potentially_plural_count(expected_count, "parameter"), potentially_plural_count(expected_count, "argument"),
potentially_plural_count(arg_count, "parameter"), potentially_plural_count(arg_count, "argument"),
if arg_count == 1 { "was" } else { "were" } if arg_count == 1 { "was" } else { "were" }
), ),
DiagnosticId::Error(error_code.to_owned()), DiagnosticId::Error(error_code.to_owned()),
); );
let label = format!("supplied {}", potentially_plural_count(arg_count, "argument"));
for (i, span) in arg_spans.into_iter().enumerate() {
err.span_label(
span,
if arg_count == 0 || i + 1 == arg_count { &label } else { "" },
);
}
if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().def_span(sp)) { if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().def_span(sp)) {
err.span_label(def_s, "defined here"); err.span_label(def_s, "defined here");
@ -3870,11 +3911,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
); );
} else { } else {
err.span_label( err.span_label(
sp, span,
format!( format!(
"expected {}{}", "expected {}{}",
if c_variadic { "at least " } else { "" }, if c_variadic { "at least " } else { "" },
potentially_plural_count(expected_count, "parameter") potentially_plural_count(expected_count, "argument")
), ),
); );
} }
@ -5622,8 +5663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx.sess.span_err( self.tcx.sess.span_err(
span, span,
"this function can only be invoked \ "this function can only be invoked directly, not through a function pointer",
directly, not through a function pointer",
); );
} }

View File

@ -1,4 +1,4 @@
// error-pattern: parameters were supplied // error-pattern: arguments were supplied
fn f(x: isize) { } fn f(x: isize) { }

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/arg-count-mismatch.rs:5:28 --> $DIR/arg-count-mismatch.rs:5:28
| |
LL | fn f(x: isize) { } LL | fn f(x: isize) { }
| -------------- defined here | -------------- defined here
LL | LL |
LL | fn main() { let i: (); i = f(); } LL | fn main() { let i: (); i = f(); }
| ^^^ expected 1 parameter | ^-- supplied 0 arguments
| |
| expected 1 argument
error: aborting due to previous error error: aborting due to previous error

View File

@ -13,8 +13,8 @@ extern "C" fn bar(f: isize, x: u8) {}
fn main() { fn main() {
unsafe { unsafe {
foo(); //~ ERROR this function takes at least 2 parameters but 0 parameters were supplied foo(); //~ ERROR this function takes at least 2 arguments but 0 arguments were supplied
foo(1); //~ ERROR this function takes at least 2 parameters but 1 parameter was supplied foo(1); //~ ERROR this 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

@ -4,23 +4,27 @@ error[E0045]: C-variadic function must have C or cdecl calling convention
LL | fn printf(_: *const u8, ...); LL | fn printf(_: *const u8, ...);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied
--> $DIR/variadic-ffi-1.rs:16:9 --> $DIR/variadic-ffi-1.rs:16:9
| |
LL | fn foo(f: isize, x: u8, ...); LL | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here | ----------------------------- defined here
... ...
LL | foo(); LL | foo();
| ^^^^^ expected at least 2 parameters | ^^^-- supplied 0 arguments
| |
| expected at least 2 arguments
error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied error[E0060]: this function takes at least 2 arguments but 1 argument was supplied
--> $DIR/variadic-ffi-1.rs:17:9 --> $DIR/variadic-ffi-1.rs:17:9
| |
LL | fn foo(f: isize, x: u8, ...); LL | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here | ----------------------------- defined here
... ...
LL | foo(1); LL | foo(1);
| ^^^^^^ expected at least 2 parameters | ^^^ - supplied 1 argument
| |
| expected at least 2 arguments
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/variadic-ffi-1.rs:19:56 --> $DIR/variadic-ffi-1.rs:19:56

View File

@ -1,14 +1,18 @@
error[E0057]: this function takes 1 parameter but 0 parameters were supplied error[E0057]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/E0057.rs:3:13 --> $DIR/E0057.rs:3:13
| |
LL | let a = f(); LL | let a = f();
| ^^^ expected 1 parameter | ^-- supplied 0 arguments
| |
| expected 1 argument
error[E0057]: this function takes 1 parameter but 2 parameters were supplied error[E0057]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/E0057.rs:5:13 --> $DIR/E0057.rs:5:13
| |
LL | let c = f(2, 3); LL | let c = f(2, 3);
| ^^^^^^^ expected 1 parameter | ^ - - supplied 2 arguments
| |
| expected 1 argument
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -5,5 +5,5 @@ extern "C" {
fn main() { fn main() {
unsafe { printf(); } unsafe { printf(); }
//~^ ERROR E0060 //~^ ERROR E0060
//~| expected at least 1 parameter //~| expected at least 1 argument
} }

View File

@ -1,11 +1,13 @@
error[E0060]: this function takes at least 1 parameter but 0 parameters were supplied error[E0060]: this function takes at least 1 argument but 0 arguments were supplied
--> $DIR/E0060.rs:6:14 --> $DIR/E0060.rs:6:14
| |
LL | fn printf(_: *const u8, ...) -> u32; LL | fn printf(_: *const u8, ...) -> u32;
| ------------------------------------ defined here | ------------------------------------ defined here
... ...
LL | unsafe { printf(); } LL | unsafe { printf(); }
| ^^^^^^^^ expected at least 1 parameter | ^^^^^^-- supplied 0 arguments
| |
| expected at least 1 argument
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,9 +5,9 @@ fn f2(a: u16) {}
fn main() { fn main() {
f(0); f(0);
//~^ ERROR E0061 //~^ ERROR E0061
//~| expected 2 parameters //~| expected 2 arguments
f2(); f2();
//~^ ERROR E0061 //~^ ERROR E0061
//~| expected 1 parameter //~| expected 1 argument
} }

View File

@ -1,20 +1,24 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/E0061.rs:6:5 --> $DIR/E0061.rs:6:5
| |
LL | fn f(a: u16, b: &str) {} LL | fn f(a: u16, b: &str) {}
| --------------------- defined here | --------------------- defined here
... ...
LL | f(0); LL | f(0);
| ^^^^ expected 2 parameters | ^ - supplied 1 argument
| |
| expected 2 arguments
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/E0061.rs:10:5 --> $DIR/E0061.rs:10:5
| |
LL | fn f2(a: u16) {} LL | fn f2(a: u16) {}
| ------------- defined here | ------------- defined here
... ...
LL | f2(); LL | f2();
| ^^^^ expected 1 parameter | ^^-- supplied 0 arguments
| |
| expected 1 argument
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

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

View File

@ -1,4 +1,4 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/issue-58451.rs:12:9 --> $DIR/issue-58451.rs:12:9
| |
LL | / fn f<I>(i: I) LL | / fn f<I>(i: I)
@ -9,7 +9,9 @@ LL | | {}
| |__- defined here | |__- defined here
... ...
LL | f(&[f()]); LL | f(&[f()]);
| ^^^ expected 1 parameter | ^-- supplied 0 arguments
| |
| expected 1 argument
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,8 +1,10 @@
error[E0057]: this function takes 0 parameters but 1 parameter was supplied error[E0057]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/issue-16939.rs:5:9 --> $DIR/issue-16939.rs:5:9
| |
LL | |t| f(t); LL | |t| f(t);
| ^^^^ expected 0 parameters | ^ - supplied 1 argument
| |
| expected 0 arguments
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-18819.rs:16:5 --> $DIR/issue-18819.rs:16:5
| |
LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) { LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) {
| ----------------------------------------------- defined here | ----------------------------------------------- defined here
... ...
LL | print_x(X); LL | print_x(X);
| ^^^^^^^^^^ expected 2 parameters | ^^^^^^^ - supplied 1 argument
| |
| expected 2 arguments
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,13 +1,13 @@
macro_rules! some_macro { macro_rules! some_macro {
($other: expr) => ({ ($other: expr) => ({
$other(None) $other(None) //~ NOTE supplied 1 argument
//~^ this function takes 0 parameters but 1 parameter was supplied
}) })
} }
fn some_function() {} fn some_function() {} //~ NOTE defined here
fn main() { fn main() {
some_macro!(some_function); some_macro!(some_function);
//~^ in this expansion of some_macro! //~^ ERROR this function takes 0 arguments but 1 argument was supplied
//~| NOTE expected 0 arguments
} }

View File

@ -1,16 +1,14 @@
error[E0061]: this function takes 0 parameters but 1 parameter was supplied error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/issue-26094.rs:3:9 --> $DIR/issue-26094.rs:10:17
| |
LL | $other(None) LL | $other(None)
| ^^^^^^^^^^^^ expected 0 parameters | ---- supplied 1 argument
... ...
LL | fn some_function() {} LL | fn some_function() {}
| ------------------ defined here | ------------------ defined here
... ...
LL | some_macro!(some_function); LL | some_macro!(some_function);
| --------------------------- in this macro invocation | ^^^^^^^^^^^^^ expected 0 arguments
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,5 +2,5 @@ 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 parameters but 1 parameter was supplied //~^^ ERROR this function takes 2 arguments but 1 argument was supplied
} }

View File

@ -1,8 +1,12 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied error[E0061]: this function 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| {
| ^^^^ expected 2 parameters | _______________________^^^^_-
| | |
| | expected 2 arguments
LL | | });
| |_____- supplied 1 argument
error: aborting due to previous error error: aborting due to previous error

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 parameter but 2 parameters were supplied //~^ ERROR this function takes 1 argument but 2 arguments were supplied

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 1 parameter but 2 parameters were supplied error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/issue-4935.rs:5:13 --> $DIR/issue-4935.rs:5:13
| |
LL | fn foo(a: usize) {} LL | fn foo(a: usize) {}
| ---------------- defined here | ---------------- defined here
LL | LL |
LL | fn main() { foo(5, 6) } LL | fn main() { foo(5, 6) }
| ^^^^^^^^^ expected 1 parameter | ^^^ - - supplied 2 arguments
| |
| expected 1 argument
error: aborting due to previous error error: aborting due to previous error

View File

@ -5,16 +5,18 @@ impl Foo {
fn zero(self) -> Foo { self } fn zero(self) -> Foo { self }
fn one(self, _: isize) -> Foo { self } fn one(self, _: isize) -> Foo { self }
fn two(self, _: isize, _: isize) -> Foo { self } fn two(self, _: isize, _: isize) -> Foo { self }
fn three<T>(self, _: T, _: T, _: T) -> Foo { self }
} }
fn main() { fn main() {
let x = Foo; let x = Foo;
x.zero(0) //~ ERROR this function takes 0 parameters but 1 parameter was supplied x.zero(0) //~ ERROR this function takes 0 arguments but 1 argument was supplied
.one() //~ ERROR this function takes 1 parameter but 0 parameters were supplied .one() //~ ERROR this function takes 1 argument but 0 arguments were supplied
.two(0); //~ ERROR this function takes 2 parameters but 1 parameter was supplied .two(0); //~ ERROR this function takes 2 arguments but 1 argument was supplied
let y = Foo; let y = Foo;
y.zero() y.zero()
.take() //~ ERROR no method named `take` found .take() //~ ERROR no method named `take` found
.one(0); .one(0);
y.three::<usize>(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied
} }

View File

@ -1,32 +1,38 @@
error[E0061]: this function takes 0 parameters but 1 parameter was supplied error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:12:7 --> $DIR/method-call-err-msg.rs:13:7
| |
LL | fn zero(self) -> Foo { self } LL | fn zero(self) -> Foo { self }
| -------------------- defined here | -------------------- defined here
... ...
LL | x.zero(0) LL | x.zero(0)
| ^^^^ expected 0 parameters | ^^^^ - supplied 1 argument
| |
| expected 0 arguments
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:13:7 --> $DIR/method-call-err-msg.rs:14:7
| |
LL | fn one(self, _: isize) -> Foo { self } LL | fn one(self, _: isize) -> Foo { self }
| ----------------------------- defined here | ----------------------------- defined here
... ...
LL | .one() LL | .one()
| ^^^ expected 1 parameter | ^^^- supplied 0 arguments
| |
| expected 1 argument
error[E0061]: this function takes 2 parameters but 1 parameter was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/method-call-err-msg.rs:14:7 --> $DIR/method-call-err-msg.rs:15:7
| |
LL | fn two(self, _: isize, _: isize) -> Foo { self } LL | fn two(self, _: isize, _: isize) -> Foo { self }
| --------------------------------------- defined here | --------------------------------------- defined here
... ...
LL | .two(0); LL | .two(0);
| ^^^ expected 2 parameters | ^^^ - supplied 1 argument
| |
| expected 2 arguments
error[E0599]: no method named `take` found for struct `Foo` in the current scope error[E0599]: no method named `take` found for struct `Foo` in the current scope
--> $DIR/method-call-err-msg.rs:18:7 --> $DIR/method-call-err-msg.rs:19:7
| |
LL | pub struct Foo; LL | pub struct Foo;
| --------------- method `take` not found for this | --------------- method `take` not found for this
@ -41,7 +47,18 @@ LL | .take()
candidate #1: `std::io::Read` candidate #1: `std::io::Read`
candidate #2: `std::iter::Iterator` candidate #2: `std::iter::Iterator`
error: aborting due to 4 previous errors error[E0061]: this function takes 3 arguments but 0 arguments were supplied
--> $DIR/method-call-err-msg.rs:21:7
|
LL | fn three<T>(self, _: T, _: T, _: T) -> Foo { self }
| ------------------------------------------ defined here
...
LL | y.three::<usize>();
| ^^^^^--------- supplied 0 arguments
| |
| expected 3 arguments
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0061, E0599. Some errors have detailed explanations: E0061, E0599.
For more information about an error, try `rustc --explain E0061`. For more information about an error, try `rustc --explain E0061`.

View File

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

View File

@ -4,17 +4,21 @@ error[E0308]: mismatched types
LL | let ans = s("what"); LL | let ans = s("what");
| ^^^^^^ expected `isize`, found `&str` | ^^^^^^ expected `isize`, found `&str`
error[E0057]: this function takes 1 parameter but 0 parameters were supplied error[E0057]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/overloaded-calls-bad.rs:29:15 --> $DIR/overloaded-calls-bad.rs:29:15
| |
LL | let ans = s(); LL | let ans = s();
| ^^^ expected 1 parameter | ^-- supplied 0 arguments
| |
| expected 1 argument
error[E0057]: this function takes 1 parameter but 2 parameters were supplied error[E0057]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/overloaded-calls-bad.rs:31:15 --> $DIR/overloaded-calls-bad.rs:31:15
| |
LL | let ans = s("burma", "shave"); LL | let ans = s("burma", "shave");
| ^^^^^^^^^^^^^^^^^^^ expected 1 parameter | ^ ------- ------- supplied 2 arguments
| |
| expected 1 argument
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -8,5 +8,5 @@ fn foo(a: isize, b: isize, c: isize, d:isize) {
fn main() { fn main() {
foo(1, 2, 3); foo(1, 2, 3);
//~^ ERROR this function takes 4 parameters but 3 //~^ ERROR this function takes 4 arguments but 3
} }

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 4 parameters but 3 parameters were supplied error[E0061]: this function takes 4 arguments but 3 arguments were supplied
--> $DIR/not-enough-arguments.rs:10:3 --> $DIR/not-enough-arguments.rs:10:3
| |
LL | fn foo(a: isize, b: isize, c: isize, d:isize) { LL | fn foo(a: isize, b: isize, c: isize, d:isize) {
| --------------------------------------------- defined here | --------------------------------------------- defined here
... ...
LL | foo(1, 2, 3); LL | foo(1, 2, 3);
| ^^^^^^^^^^^^ expected 4 parameters | ^^^ - - - supplied 3 arguments
| |
| expected 4 arguments
error: aborting due to previous error error: aborting due to previous error

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 parameters but 1 parameter was supplied //~| ERROR this 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

@ -10,11 +10,13 @@ error[E0412]: cannot find type `u8` in the crate root
LL | let _: ::u8; LL | let _: ::u8;
| ^^ not found in the crate root | ^^ not found in the crate root
error[E0061]: this function takes 0 parameters but 1 parameter was supplied error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/resolve-primitive-fallback.rs:3:5 --> $DIR/resolve-primitive-fallback.rs:3:5
| |
LL | std::mem::size_of(u16); LL | std::mem::size_of(u16);
| ^^^^^^^^^^^^^^^^^^^^^^ expected 0 parameters | ^^^^^^^^^^^^^^^^^ --- supplied 1 argument
| |
| expected 0 arguments
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -1,14 +1,18 @@
error[E0057]: this function takes 1 parameter but 0 parameters were supplied error[E0057]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/E0057.rs:3:13 --> $DIR/E0057.rs:3:13
| |
LL | let a = f(); LL | let a = f();
| ^^^ expected 1 parameter | ^-- supplied 0 arguments
| |
| expected 1 argument
error[E0057]: this function takes 1 parameter but 2 parameters were supplied error[E0057]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/E0057.rs:5:13 --> $DIR/E0057.rs:5:13
| |
LL | let c = f(2, 3); LL | let c = f(2, 3);
| ^^^^^^^ expected 1 parameter | ^ - - supplied 2 arguments
| |
| expected 1 argument
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -50,14 +50,16 @@ help: if this is a type, explicitly ignore the parameter name
LL | fn bar(_: x, y: usize) {} LL | fn bar(_: x, y: usize) {}
| ^^^^ | ^^^^
error[E0061]: this function takes 2 parameters but 3 parameters were supplied error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/issue-34264.rs:7:5 --> $DIR/issue-34264.rs:7:5
| |
LL | fn foo(Option<i32>, String) {} LL | fn foo(Option<i32>, String) {}
| --------------------------- defined here | --------------------------- defined here
... ...
LL | foo(Some(42), 2, ""); LL | foo(Some(42), 2, "");
| ^^^^^^^^^^^^^^^^^^^^ expected 2 parameters | ^^^ -------- - -- supplied 3 arguments
| |
| expected 2 arguments
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-34264.rs:8:13 --> $DIR/issue-34264.rs:8:13
@ -65,14 +67,16 @@ error[E0308]: mismatched types
LL | bar("", ""); LL | bar("", "");
| ^^ expected `usize`, found `&str` | ^^ expected `usize`, found `&str`
error[E0061]: this function takes 2 parameters but 3 parameters were supplied error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/issue-34264.rs:10:5 --> $DIR/issue-34264.rs:10:5
| |
LL | fn bar(x, y: usize) {} LL | fn bar(x, y: usize) {}
| ------------------- defined here | ------------------- defined here
... ...
LL | bar(1, 2, 3); LL | bar(1, 2, 3);
| ^^^^^^^^^^^^ expected 2 parameters | ^^^ - - - supplied 3 arguments
| |
| expected 2 arguments
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View File

@ -1,68 +1,72 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:11:33 --> $DIR/missing-unit-argument.rs:11:33
| |
LL | let _: Result<(), String> = Ok(); LL | let _: Result<(), String> = Ok();
| ^^^^ | ^^-- supplied 0 arguments
| |
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |
LL | let _: Result<(), String> = Ok(()); LL | let _: Result<(), String> = Ok(());
| ^^ | ^^
error[E0061]: this function takes 2 parameters but 0 parameters were supplied error[E0061]: this function takes 2 arguments but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:12:5 --> $DIR/missing-unit-argument.rs:12:5
| |
LL | fn foo(():(), ():()) {} LL | fn foo(():(), ():()) {}
| -------------------- defined here | -------------------- defined here
... ...
LL | foo(); LL | foo();
| ^^^^^ expected 2 parameters | ^^^-- supplied 0 arguments
| |
| expected 2 arguments
error[E0061]: this function takes 2 parameters but 1 parameter was supplied error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/missing-unit-argument.rs:13:5 --> $DIR/missing-unit-argument.rs:13:5
| |
LL | fn foo(():(), ():()) {} LL | fn foo(():(), ():()) {}
| -------------------- defined here | -------------------- defined here
... ...
LL | foo(()); LL | foo(());
| ^^^^^^^ expected 2 parameters | ^^^ -- supplied 1 argument
| |
| expected 2 arguments
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:14:5 --> $DIR/missing-unit-argument.rs:14:5
| |
LL | fn bar(():()) {} LL | fn bar(():()) {}
| ------------- defined here | ------------- defined here
... ...
LL | bar(); LL | bar();
| ^^^^^ | ^^^-- supplied 0 arguments
| |
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |
LL | bar(()); LL | bar(());
| ^^ | ^^
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:15:7 --> $DIR/missing-unit-argument.rs:15:7
| |
LL | fn baz(self, (): ()) { } LL | fn baz(self, (): ()) { }
| -------------------- defined here | -------------------- defined here
... ...
LL | S.baz(); LL | S.baz();
| ^^^ | ^^^- supplied 0 arguments
| |
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |
LL | S.baz(()); LL | S.baz(());
| ^^ | ^^
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/missing-unit-argument.rs:16:7 --> $DIR/missing-unit-argument.rs:16:7
| |
LL | fn generic<T>(self, _: T) { } LL | fn generic<T>(self, _: T) { }
| ------------------------- defined here | ------------------------- defined here
... ...
LL | S.generic::<()>(); LL | S.generic::<()>();
| ^^^^^^^ | ^^^^^^^------ supplied 0 arguments
| |
help: expected the unit value `()`; create it with empty parentheses help: expected the unit value `()`; create it with empty parentheses
| |

View File

@ -18,6 +18,6 @@ impl E2 {
} }
fn main() { fn main() {
<E>::V(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied <E>::V(); //~ ERROR this function takes 1 argument but 0 arguments were supplied
let _: u8 = <E2>::V; //~ ERROR mismatched types let _: u8 = <E2>::V; //~ ERROR mismatched types
} }

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/enum-variant-priority-higher-than-other-inherent.rs:21:5 --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:21:5
| |
LL | V(u8) LL | V(u8)
| ----- defined here | ----- defined here
... ...
LL | <E>::V(); LL | <E>::V();
| ^^^^^^^^ expected 1 parameter | ^^^^^^-- supplied 0 arguments
| |
| expected 1 argument
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17 --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17

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 parameter //~^ ERROR this function takes 1 argument
} }

View File

@ -7,11 +7,13 @@ LL | let x: Vec::with_capacity(10, 20);
| |help: use `=` if you meant to assign | |help: use `=` if you meant to assign
| while parsing the type for `x` | while parsing the type for `x`
error[E0061]: this function takes 1 parameter but 2 parameters were supplied error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/type-ascription-instead-of-initializer.rs:2:12 --> $DIR/type-ascription-instead-of-initializer.rs:2:12
| |
LL | let x: Vec::with_capacity(10, 20); LL | let x: Vec::with_capacity(10, 20);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter | ^^^^^^^^^^^^^^^^^^ -- -- supplied 2 arguments
| |
| expected 1 argument
error: aborting due to 2 previous errors error: aborting due to 2 previous errors