E0061 Wrong Argument Count Fix
A call and a signature disagree about how many arguments there are: one too few, one too many, a receiver counted differently than expected, a call site left behind by a signature change. This guide separates the shapes that produce E0061 and matches each one to the change that makes the counts agree: supply the argument, drop the argument, or change the signature itself.
Written November 23, 2026 · Tested with Rust 1.99.1 · 32 min read
- The rule underneath: the count must match the signature exactly
- How to read the diagnostic
- The first failure: too few arguments to a free function
- The second failure: too many arguments to a free function
Written November 23, 2026
Tested with Rust 1.99.1
What this guide is
Error E0061 is a count that does not match. The error codes index states it in one line: an invalid number of arguments was passed when calling a function. The number of arguments passed to a function must match the number of arguments specified in the function signature - exactly, in both directions. One too few is E0061, and one too many is the same E0061. The header says so in plain counts: "this function takes 2 arguments but 1 argument was supplied", or "this function takes 2 arguments but 3 arguments were supplied". The call fails on the count alone - no separate type error is emitted for it - but a supplied argument whose type is also wrong can still be annotated inside the E0061 diagnostic itself, with an "expected / found" note on that argument.
The forms in this guide each reproduce E0061 with a small, complete program, and each fails at a different kind of call site. Too few arguments to a free function, and too many. A method called without an argument its signature declares, and a method called with one extra. A function pointer called with fewer arguments than its fn type declares. A call site left stale after the function it calls gained a parameter. A constructor-like associated function, new, called with too few arguments. A tuple struct constructor called with too few fields. And a trait method that has a default body, called without its argument anyway - a default body is not a default argument. In each family the failing program is small, the full compiler output is shown, and the fix makes the two counts agree: supply the missing argument, remove the extra one, or - when the call expresses the intended shape and the signature is the stale side - change the signature and update the other call sites.
Four neighboring results are not E0061 and are worked only in the traps and the decision summary. A closure called with the wrong count carries the same wording in its header but a different code, E0057 - the callee being a closure, not a function, decides it. The right count with a wrong type is E0308, mismatched types. A method name the type does not have at all is E0599, no method named - the name fails before the count is ever checked. And calling a value that is not a function is E0618.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.
The rule underneath: the count must match the signature exactly
A function signature declares a fixed list of parameters, and a call must supply exactly one argument for each parameter - no more, no fewer. The error codes index puts the consequence plainly: a function declared as fn f(a: u16, b: &str) must always be called with exactly two arguments, for example f(2, "test"). The index adds the reason this surprises programmers arriving from other languages: Rust does not have a notion of optional function arguments or variadic functions, except for its C-FFI. There is no default value a missing argument falls back to, no trailing parameter that absorbs extras, and no overload set the compiler can pick a better-matching member from. One name, one signature, one exact count.
The signature the count is checked against is not always the one at the definition you are looking at. For a method call, the receiver is not part of the counted arguments: a method declared fn can_hold(&self, other: &Rectangle) takes, in the diagnostic's words, 1 argument, because &self is supplied by the value before the dot and is not written inside the parentheses. The Book's method chapter states the underlying rule: a method's first parameter is always self, the instance the method is called on, and method syntax supplies it from the receiver - which is why the counts in a method diagnostic run one lower than the parameter list in the impl block suggests. For a call through a function pointer, the signature that binds is the pointer's fn type, not the original function's declaration: let f: fn(i32, i32) -> i32 makes f a two-argument callee whatever it points at, and calling it with one argument is E0061 against the type. For an associated function such as Point::new, there is no receiver at all, so every declared parameter is a counted argument. And for a tuple struct, the constructor is a function whose parameters are the fields: struct Pair(i32, i32) declares a two-argument constructor, and the diagnostic calls it "this struct".
Two consequences follow. First, the fix is always one of three moves, and the diagnostic tells you which direction the mismatch runs: supply the missing argument (the help says "provide the argument" and names its type and position), remove the extra argument (the help says "remove the extra argument" and marks it), or change the signature when the call is right and the declaration is what drifted - remembering that a signature change makes every other call site a candidate for the same error. Second, count is its own question, distinct from type and from existence. The same call site can be wrong in three independent ways - the method name does not exist (E0599), the name exists but the count is wrong (E0061), or the count is right but a value's type is wrong (E0308) - and each failure on its own is reported under its own code, so reading which question failed is the whole diagnosis. When the count and a supplied argument's type are both wrong, only E0061 is emitted, with the type mismatch folded into its diagnostic as an "expected / found" note on that argument - fixing the count can then leave the type error to be reported on the next check.
How to read the diagnostic
The header gives both counts and names the kind of callee: "this function takes 2 arguments but 1 argument was supplied", "this method takes 1 argument but 0 arguments were supplied", "this struct takes 2 arguments but 1 argument was supplied". The first number is the signature's parameter count - with the method receiver already excluded, as the rule section covers - and the second is what the call supplied. Comparing the two numbers gives the direction before anything else is read: supplied lower means an argument is missing; supplied higher means one is extra.
The label under the call then identifies the exact argument. For a missing argument it reads "argument #2 of type char is missing" - the position and the type of the parameter that has no value, which is usually enough to know what to pass. For an extra argument it reads "unexpected argument #3 of type {integer}", marking the argument the signature has no parameter for. The note points back at the definition - "function defined here", "method defined here", "associated function defined here", "tuple struct defined here" - with the parameter that matters underlined, so the signature and the call can be compared on one screen.
The help is mechanical and safe to follow literally: "provide the argument", printed with the call rewritten and a typed placeholder where the value goes, or "remove the extra argument", printed with the call rewritten without it. What the help cannot decide for you is the third fix - whether the signature, rather than the call, is the side that should change. That judgment comes from which side expresses the intent: a call site that was written against an older signature is stale and gets the new argument; a signature that grew a parameter no caller needs is the over-wide side and loses it.
The first failure: too few arguments to a free function
greet declares two parameters, a name and a punctuation character. The call supplies only the name. This is the shape of the error codes index's own erroneous example - a function called with fewer arguments than its signature specifies:
fn greet(name: &str, punct: char) {
println!("Hello, {name}{punct}");
}
fn main() {
greet("Ada");
}
$ rustc --edition 2021 fail_too_few.rs -o fail_too_few
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> fail_too_few.rs:6:5
|
6 | greet("Ada");
| ^^^^^------- argument #2 of type `char` is missing
|
note: function defined here
--> fail_too_few.rs:1:4
|
1 | fn greet(name: &str, punct: char) {
| ^^^^^ -----------
help: provide the argument
|
6 | greet("Ada", /* char */);
| ++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The header counts 2 against 1, and the label names the missing piece exactly: "argument #2 of type char is missing". The note underlines the punct: char parameter in the definition, and the help rewrites the call with a /* char */ placeholder in the empty position. The fix supplies that argument:
fn greet(name: &str, punct: char) {
println!("Hello, {name}{punct}");
}
fn main() {
greet("Ada", '!');
}
$ rustc --edition 2021 fix_too_few.rs -o fix_too_few
$ ./fix_too_few
Hello, Ada!
The output is Hello, Ada! - the greeting with the punctuation the second parameter carries. There is no shorter call that works: Rust has no default argument for punct to fall back to, so a caller that does not care about punctuation still passes a character explicitly, or the program grows a second function - a differently named one, since there is no overloading either - that supplies it.
The second failure: too many arguments to a free function
The same rule in the other direction. add declares two parameters; the call supplies three values:
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
println!("{}", add(2, 3, 4));
}
$ rustc --edition 2021 fail_too_many.rs -o fail_too_many
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> fail_too_many.rs:6:20
|
6 | println!("{}", add(2, 3, 4));
| ^^^ - unexpected argument #3 of type `{integer}`
|
note: function defined here
--> fail_too_many.rs:1:4
|
1 | fn add(a: i32, b: i32) -> i32 {
| ^^^
help: remove the extra argument
|
6 - println!("{}", add(2, 3, 4));
6 + println!("{}", add(2, 3));
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The header counts 2 against 3, and the caret marks only the third value: "unexpected argument #3 of type {integer}". The extra argument is not ignored, truncated, or folded into the others - the call is rejected whole. The help performs the removal it recommends, and the fix is that call:
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
println!("{}", add(2, 3));
}
$ rustc --edition 2021 fix_too_many.rs -o fix_too_many
$ ./fix_too_many
5
The output is 5. When the extra value was carrying real information - here, a third number the caller genuinely wanted added - removing it is the wrong fix, and the signature is the side to change: add grows a third parameter, and every existing two-argument call site in the program then fails with the first family's error until it is updated. The count must match; which side moves is a design decision the diagnostic deliberately does not make.
The third failure: a method called without its argument
can_hold is a method on Rectangle: beyond the receiver, it declares one parameter, the other rectangle. The call supplies the receiver - the value before the dot - and nothing in the parentheses:
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn can_hold(&self, other: &Rectangle) -> bool {
self.width > other.width && self.height > other.height
}
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!("{}", rect1.can_hold());
}
$ rustc --edition 2021 fail_method_missing.rs -o fail_method_missing
error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> fail_method_missing.rs:14:26
|
14 | println!("{}", rect1.can_hold());
| ^^^^^^^^-- argument #1 of type `&Rectangle` is missing
|
note: method defined here
--> fail_method_missing.rs:7:8
|
7 | fn can_hold(&self, other: &Rectangle) -> bool {
| ^^^^^^^^ -----------------
help: provide the argument
|
14 | println!("{}", rect1.can_hold(/* &Rectangle */));
| ++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The header reads "this method takes 1 argument but 0 arguments were supplied" - and the 1 is the count after the receiver. The signature lists two parameters, &self and other, but &self is supplied by rect1 itself, so the diagnostic counts only other: &Rectangle, and its label reads "argument #1 of type &Rectangle is missing". Reading a method diagnostic with the receiver included produces an off-by-one hunt for an argument that is not missing; the count in the header is already receiver-free.
The fourth failure: a method called with an extra argument
area declares no parameter beyond the receiver. The call passes a value anyway:
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height
}
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!("{}", rect1.area(2));
}
$ rustc --edition 2021 fail_method_extra.rs -o fail_method_extra
error[E0061]: this method takes 0 arguments but 1 argument was supplied
--> fail_method_extra.rs:14:26
|
14 | println!("{}", rect1.area(2));
| ^^^^ - unexpected argument of type `{integer}`
|
note: method defined here
--> fail_method_extra.rs:7:8
|
7 | fn area(&self) -> u32 {
| ^^^^
help: remove the extra argument
|
14 - println!("{}", rect1.area(2));
14 + println!("{}", rect1.area());
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The header counts 0 against 1: "this method takes 0 arguments but 1 argument was supplied". A method whose whole parameter list is &self takes no written arguments at all, and the 2 in the call has nowhere to go - the label marks it "unexpected argument of type {integer}", and the help removes it. This shape usually means the caller expected a different method than the one named - a scaled or parameterized variant that does not exist - so check the name against the impl block before deleting the value; if the variant is genuinely wanted, it is a new method to write, not an argument the existing one can absorb.
Both method fixes together - each call supplying exactly the arguments its signature counts:
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height
}
fn can_hold(&self, other: &Rectangle) -> bool {
self.width > other.width && self.height > other.height
}
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
let rect2 = Rectangle { width: 10, height: 40 };
println!("{}", rect1.area());
println!("{}", rect1.can_hold(&rect2));
}
$ rustc --edition 2021 fix_methods.rs -o fix_methods
$ ./fix_methods
1500
true
The output is 1500, the area of the 30-by-50 rectangle, then true - the 10-by-40 rectangle fits inside it on both dimensions. area() is called with empty parentheses and can_hold(&rect2) with the one argument its signature counts, and the receiver appears in neither count.
The fifth failure: a function pointer called with the wrong arity
A function value can be called through a variable, and then the variable's type is the signature. Here f is declared with the function pointer type fn(i32, i32) -> i32 and holds add - and is called with one argument:
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
let f: fn(i32, i32) -> i32 = add;
println!("{}", f(5));
}
$ rustc --edition 2021 fail_fnptr.rs -o fail_fnptr
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> fail_fnptr.rs:7:20
|
7 | println!("{}", f(5));
| ^--- argument #2 of type `i32` is missing
|
help: provide the argument
|
7 | println!("{}", f(5, /* i32 */));
| +++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The header is the free-function form - "this function takes 2 arguments but 1 argument was supplied" - but there is no "function defined here" note, because the callee is a value, not a named function item. The signature the count was checked against is the fn(i32, i32) -> i32 in the let annotation: a function pointer type, as the Reference describes it, is written with the fn keyword and carries its parameter types in the type itself. The fix supplies the second argument the type declares:
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
let f: fn(i32, i32) -> i32 = add;
println!("{}", f(5, 7));
}
$ rustc --edition 2021 fix_fnptr.rs -o fix_fnptr
$ ./fix_fnptr
12
The output is 12. When the failing call goes through a variable, read the arity off the variable's declared fn type, not off the function that was assigned to it - the two agree at the assignment, but the type is what every later call is checked against, and reassigning f to a different two-argument function changes nothing about what its calls must supply.
The sixth failure: a call site left stale by a signature change
This family is the first family seen from the other side of an edit. total takes a price and a tax amount - the signature it has now, after a change that added the tax parameter. The call still passes only the price, exactly as it did when total took one parameter and the call was correct:
fn total(price: i32, tax: i32) -> i32 {
price + tax
}
fn main() {
println!("{}", total(100));
}
$ rustc --edition 2021 fail_stale.rs -o fail_stale
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> fail_stale.rs:6:20
|
6 | println!("{}", total(100));
| ^^^^^----- argument #2 of type `i32` is missing
|
note: function defined here
--> fail_stale.rs:1:4
|
1 | fn total(price: i32, tax: i32) -> i32 {
| ^^^^^ --------
help: provide the argument
|
6 | println!("{}", total(100, /* i32 */));
| +++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The diagnostic is identical in shape to the first family's - the compiler cannot tell a call that was always wrong from a call that an edit made wrong, and does not try. The note underlines the new tax: i32 parameter, which is the tell when reading a fresh E0061 in code that used to compile: the underlined parameter is the one the call predates. The fix updates the call to the current signature:
fn total(price: i32, tax: i32) -> i32 {
price + tax
}
fn main() {
println!("{}", total(100, 13));
}
$ rustc --edition 2021 fix_stale.rs -o fix_stale
$ ./fix_stale
113
The output is 113, price plus tax. A signature change is not finished when the definition compiles: every call site in the crate is part of the change, and the compiler finds the un-updated ones one crate-check at a time, each as its own E0061. The reverse edit is just as common - a parameter removed from a signature leaves its former callers in the second family's shape, passing an argument that is now unexpected.
The seventh failure: a constructor-like associated function called with too few arguments
new is not a keyword or a language feature. As the Book's method chapter covers, associated functions that are not methods - functions in an impl block with no self parameter - are often used for constructors that return a new instance of the struct, and are often called new, but new is not a special name and is not built into the language. A call to one is an ordinary function call through a path, Point::new, and its count rule is the ordinary one - with no receiver to absorb a parameter, every declared parameter is counted:
struct Point {
x: i32,
y: i32,
}
impl Point {
fn new(x: i32, y: i32) -> Point {
Point { x, y }
}
}
fn main() {
let p = Point::new(3);
println!("{}, {}", p.x, p.y);
}
$ rustc --edition 2021 fail_new.rs -o fail_new
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> fail_new.rs:13:13
|
13 | let p = Point::new(3);
| ^^^^^^^^^^--- argument #2 of type `i32` is missing
|
note: associated function defined here
--> fail_new.rs:7:8
|
7 | fn new(x: i32, y: i32) -> Point {
| ^^^ ------
help: provide the argument
|
13 | let p = Point::new(3, /* i32 */);
| +++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The note is the associated-function form - "associated function defined here" - and the header counts the full parameter list, 2 against 1, because there is no self for a receiver to supply. Compare the third family: a method's diagnostic excludes the receiver from both the count and the numbering, while an associated function's diagnostic includes every parameter, so the same impl block produces two different counting conventions depending on whether the first parameter is self. The fix supplies the second coordinate:
struct Point {
x: i32,
y: i32,
}
impl Point {
fn new(x: i32, y: i32) -> Point {
Point { x, y }
}
}
fn main() {
let p = Point::new(3, 4);
println!("{}, {}", p.x, p.y);
}
$ rustc --edition 2021 fix_new.rs -o fix_new
$ ./fix_new
3, 4
The output is 3, 4, the two fields of the constructed point. When a constructor call is short an argument, the missing value is a design question before it is a typing question - a y of 0, a second point to copy from, or a differently shaped constructor such as a from_x that supplies the rest - because the argument was declared precisely so that every constructed value has it.
The eighth failure: a tuple struct constructor called with too few fields
A tuple struct's constructor is a function whose parameters are its fields, in order. Pair declares two fields, so its constructor takes two arguments - and a call with one fails under the same code, with the callee named as a struct:
struct Pair(i32, i32);
fn main() {
let p = Pair(3);
println!("{}, {}", p.0, p.1);
}
$ rustc --edition 2021 fail_tuplestruct.rs -o fail_tuplestruct
error[E0061]: this struct takes 2 arguments but 1 argument was supplied
--> fail_tuplestruct.rs:4:13
|
4 | let p = Pair(3);
| ^^^^--- argument #2 of type `i32` is missing
|
note: tuple struct defined here
--> fail_tuplestruct.rs:1:8
|
1 | struct Pair(i32, i32);
| ^^^^
help: provide the argument
|
4 | let p = Pair(3, /* i32 */);
| +++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The header reads "this struct takes 2 arguments but 1 argument was supplied", and the note reads "tuple struct defined here", pointing at the declaration whose field list is the parameter list. There is no body and no fn anywhere in this family - the constructor exists because the struct declaration creates it, and its arity is the field count. The fix supplies the second field:
struct Pair(i32, i32);
fn main() {
let p = Pair(3, 4);
println!("{}, {}", p.0, p.1);
}
$ rustc --edition 2021 fix_tuplestruct.rs -o fix_tuplestruct
$ ./fix_tuplestruct
3, 4
The output is 3, 4, read back through the positional field names p.0 and p.1. The same count rule applies to tuple variants of enums, which are also constructed by calling the variant with one argument per field. A braced struct literal is a different construction form with different errors - a missing field there is not E0061 - so when a construction fails, check which of the two forms the code uses before reading the count.
The ninth failure: a trait method with a default body, called without its argument
A trait method can carry a default body, an implementation every implementor gets for free. What it cannot carry is a default argument: the body is what runs when the method is called, not a value that stands in for a missing call argument. describe has a default body and one parameter beyond the receiver, and Item implements the trait without overriding it - and the call still has to supply the parameter:
trait Describe {
fn describe(&self, prefix: &str) -> String {
format!("{prefix} item")
}
}
struct Item;
impl Describe for Item {}
fn main() {
let item = Item;
println!("{}", item.describe());
}
$ rustc --edition 2021 fail_traitmethod.rs -o fail_traitmethod
error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> fail_traitmethod.rs:13:25
|
13 | println!("{}", item.describe());
| ^^^^^^^^-- argument #1 of type `&str` is missing
|
note: method defined here
--> fail_traitmethod.rs:2:8
|
2 | fn describe(&self, prefix: &str) -> String {
| ^^^^^^^^ ------------
help: provide the argument
|
13 | println!("{}", item.describe(/* &str */));
| ++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0061`.
The note points into the trait definition - "method defined here", at the declaration inside trait Describe - because Item never overrode the method, so the trait's signature is the only one there is. The count is the method count, receiver excluded: 1 declared, 0 supplied. A default body changes who writes the implementation, never what a call must pass; the error codes index's rule that Rust has no optional arguments admits no exception for trait methods. The fix supplies the prefix:
trait Describe {
fn describe(&self, prefix: &str) -> String {
format!("{prefix} item")
}
}
struct Item;
impl Describe for Item {}
fn main() {
let item = Item;
println!("{}", item.describe("one"));
}
$ rustc --edition 2021 fix_traitmethod.rs -o fix_traitmethod
$ ./fix_traitmethod
one item
The output is one item - the supplied prefix run through the default body Item inherited. If most callers pass the same prefix, the Rust shape for that is a second, differently named method that supplies it - a describe_default that calls describe with the common value - not a shorter call to describe itself.
The fixes in reach order
- The header counts a function short ("takes 2 arguments but 1 argument was supplied") and the label names the missing argument's position and type: supply it, as the help's rewritten call shows.
- The header counts a function over ("takes 2 arguments but 3 arguments were supplied") and the label marks an "unexpected argument": remove it - or, if the value carries information the function needs, widen the signature and update every other call site to the new count.
- The header says "this method": the counts exclude the receiver. A missing argument is the parameter after
&self; an argument passed to a&self-only method is unexpected and comes out. - The call goes through a variable: read the arity off the variable's
fnpointer type, and make the call match that type. - The error appeared right after a signature edit: the call site is stale. Update it to the current signature - and search for the function's other call sites, which the same edit left in the same state.
- The note says "associated function defined here": there is no receiver, so the full parameter list counts - supply every parameter,
newincluded. - The note says "tuple struct defined here": the field list is the parameter list - supply one argument per field, in field order.
- The note points into a trait definition: the method's default body does not make any argument optional - supply the argument, or add a differently named convenience method that supplies it for you.
Traps
- A closure called with the wrong count is E0057, not E0061. The header's wording is identical - the split is what the callee is. A closure is an anonymous function value, as the Book's closures chapter covers, and the error codes index gives closure calls their own code: an invalid number of arguments was given when calling a closure:
fn main() {
let scale = |x: i32, factor: i32| x * factor;
println!("{}", scale(6));
}
$ rustc --edition 2021 fail_closure.rs -o fail_closure
error[E0057]: this function takes 2 arguments but 1 argument was supplied
--> fail_closure.rs:3:20
|
3 | println!("{}", scale(6));
| ^^^^^--- argument #2 of type `i32` is missing
|
note: closure defined here
--> fail_closure.rs:2:17
|
2 | let scale = |x: i32, factor: i32| x * factor;
| ^^^^^^^^^^^^^^^^^^^^^
help: provide the argument
|
3 | println!("{}", scale(6, /* i32 */));
| +++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0057`.
|x: i32, factor: i32| parameter list, where an E0061 note points at an fn definition or an fn type. The fix is the same move as any missing argument - supply it:fn main() {
let scale = |x: i32, factor: i32| x * factor;
println!("{}", scale(6, 3));
}
$ rustc --edition 2021 fix_closure.rs -o fix_closure
$ ./fix_closure
18
The output is 18. The index adds that calls to values implementing the function traits Fn, FnMut, or FnOnce through call notation are counted the same way, under E0057 - so any callee that is a value with a closure-like type, rather than a function item, a method, or a function pointer, lands on E0057 when its count is wrong. A function pointer variable, as the fifth family shows, stays E0061: the pointer's fn type is a function signature, not a closure type.
- The right count with a wrong type is E0308, not E0061. Here the call supplies exactly the one argument plus_one declares - and the argument is a string where an i32 belongs:
fn plus_one(x: i32) -> i32 {
x + 1
}
fn main() {
println!("{}", plus_one("5"));
}
$ rustc --edition 2021 probe_e0308.rs -o probe_e0308
error[E0308]: mismatched types
--> probe_e0308.rs:6:29
|
6 | println!("{}", plus_one("5"));
| -------- ^^^ expected `i32`, found `&str`
| |
| arguments to this function are incorrect
|
note: function defined here
--> probe_e0308.rs:1:4
|
1 | fn plus_one(x: i32) -> i32 {
| ^^^^^^^^ ------
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
The header reads "mismatched types", the label reads "expected i32, found &str", and the sub-label reads "arguments to this function are incorrect" - a type judgment, with no counts anywhere in it. The error codes index defines E0308 as an expected type that did not match the received type, most commonly when calling a function and passing an argument of a different type than the declaration. Count first, type second: a call can pass the count check and fail the type check, and fixing the count of a call whose real problem is a type - or the type of a call whose real problem is the count - leaves an error standing either way.
- A method name the type does not have is E0599, not E0061. Nothing here is miscounted - chocolate is not a method of Mouth at any argument count:
struct Mouth;
fn main() {
let x = Mouth;
x.chocolate();
}
$ rustc --edition 2021 probe_e0599.rs -o probe_e0599
error[E0599]: no method named `chocolate` found for struct `Mouth` in the current scope
--> probe_e0599.rs:5:7
|
1 | struct Mouth;
| ------------ method `chocolate` not found for this struct
...
5 | x.chocolate();
| ^^^^^^^^^ method not found in `Mouth`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0599`.
The header reads "no method named chocolate found for struct Mouth in the current scope" - this is the error codes index's own erroneous example for E0599, which occurs when a method is used on a type that does not implement it. Existence is checked before counting: the compiler cannot compare a call's arguments against a signature that does not exist, so a misspelled or misremembered method name reports E0599 however many arguments the call passes, and adding or removing arguments cannot fix it. The name - or the trait that provides it, brought into scope - is the fix.
- Calling a value that is not a function is E0618, not E0061. The parentheses are present and empty, so the count is not even wrong - the callee is an integer:
fn main() {
let x = 0i32;
x();
}
$ rustc --edition 2021 probe_e0618.rs -o probe_e0618
error[E0618]: expected function, found `i32`
--> probe_e0618.rs:3:5
|
2 | let x = 0i32;
| - `x` has type `i32`
3 | x();
| ^--
| |
| call expression requires function
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0618`.
The header reads "expected function, found i32", and the label reads "call expression requires function". The error codes index defines E0618 as an attempt to call something which is not a function nor a method - only functions and methods can be called using (). This shape appears most often when a variable shadows a function of the same name: the binding wins, the call lands on the value, and the error is about the callee's kind, not its arguments. Rename the variable or the function; no change to the argument list reaches this error.
Decision summary
- The header says "this function takes N arguments but M arguments were supplied" under E0061, with M below N and a label naming the missing argument's position and type: supply that argument - or narrow the signature if no caller can supply it.
- The same header with M above N, and a label marking an "unexpected argument": remove that argument - or widen the signature and update every other call site if the value belongs in the call.
- The header says "this method": both counts exclude the receiver. Count the parameters after
selfin the signature against the values inside the call's parentheses, nothing else. - The header says "this struct" and the note says "tuple struct defined here": the field list is the parameter list - one argument per field, in order.
- The note says "associated function defined here": no receiver exists, so the whole parameter list counts, constructors included.
- The note says "closure defined here" and the code is E0057: the callee is a closure or a function-trait value - same count rule, same fix, different code.
- The header says "mismatched types" (E0308) with an "expected / found" label: the count is right and a type is wrong - fix the value or the parameter type, not the number of arguments.
- The header says "no method named" (E0599): the name does not exist on the type - fix the name or bring the providing trait into scope; the argument count is not yet being judged.
- The header says "expected function, found" a value type (E0618): the callee is not callable at all - most often a variable shadowing a function name.
Checklist
- Both counts read off the header: what the signature takes, what the call supplied - and the direction of the mismatch settled before editing.
- For a method, the receiver excluded from both sides of the comparison: parameters after
selfagainst values inside the parentheses. - The labeled argument identified: the missing one's position and type, or the extra one's position - the label, not a guess, picks the value to add or remove.
- The binding signature identified for indirect calls: the
fntype for a function pointer, the trait definition for an un-overridden trait method, the field list for a tuple struct. - Staleness considered when the code used to compile: a signature that gained or lost a parameter leaves its un-updated call sites as E0061, in both directions.
- No default expected anywhere: Rust has no optional or default arguments, and a default method body is not one - a shorter call is never a legal spelling of a longer signature.
- The neighboring questions separated: name exists (not E0599), callee is callable (not E0618), callee is a function rather than a closure (not E0057), types match (not E0308) - count is only one of the four checks a call passes.
- The fixed program run, and its output checked against what the failing program was trying to compute.
Related guides on this site
Sources
- Rust, Error codes index: E0061 - the definition of the error: an invalid number of arguments was passed when calling a function; the number passed must match the number specified in the function signature, and Rust has no optional function arguments or variadic functions except for its C-FFI.
- The Rust Programming Language, Functions - parameters as part of a function's signature, arguments as the concrete values supplied at a call, and the requirement to declare the type of each parameter.
- The Rust Programming Language, Method Syntax - methods defined in an
implblock withselfas the first parameter supplied by the receiver, and associated functions withoutself- often used as constructors and often callednew, which is not a special name - called through the type with::. - The Rust Reference, Function pointer types - the
fnpointer type written with thefnkeyword, carrying its parameter and return types in the type itself, so a call through a pointer is checked against the type's arity. - The Rust Reference, Functions - the function item itself: a name, a set of parameters through which the caller passes arguments, and an output type; a first parameter that is a self parameter makes the function a method, and a
...parameter marks a C-variadic function. - Rust, Error codes index: E0057 - the neighboring count error: an invalid number of arguments was given when calling a closure, including calls through the
Fn,FnMut, andFnOncetraits - the same count rule as E0061, split off by the callee being a closure. - Rust, Error codes index: E0308 - the neighboring type error: the expected type did not match the received type, most commonly an argument of a different type than the function declaration specifies.
- Rust, Error codes index: E0599 - the neighboring existence error: a method was used on a type which does not implement it, so the name is not found as a method on the receiver.
- Rust, Error codes index: E0618 - the neighboring callee error: an attempt to call something which is not a function nor a method; only functions and methods can be called using
(). - The Rust Programming Language, Closures - closures as anonymous functions that can be saved in a variable and called through it, the call form whose wrong-count error is E0057 rather than E0061.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.