Rust

E0057 Invalid Number of Arguments Fix

You call a closure with one argument too few, or one too many, and the compiler stops with E0057: this function takes 1 argument but 0 arguments were supplied. A closure has no default arguments and no overloads - the call has to supply exactly the parameters the closure takes. This guide shows each failing shape, where the error is reported for each one, the neighboring shapes that draw E0061 instead, and the repairs: match the call to the closure, or change the closure so the call you want to write is the right one.

Written December 2, 2026 · Tested with Rust 1.99.1 · 20 min read

By the end of this guide
  • The rule underneath: the call must match the parameter count exactly
  • How to read the diagnostic
  • The first failure: the index example
  • Each bad call on its own

Written December 2, 2026

Tested with Rust 1.99.1

What this guide is

Error E0057 means a call supplied the wrong number of arguments. The error codes index puts it in one sentence: "An invalid number of arguments was given when calling a closure."

In the shapes probed in this guide, E0057 fires when the value being called is a closure, or a generic parameter bounded by one of the function traits - Fn, FnMut, or FnOnce - and the call passes fewer or more arguments than the definition takes. The same mismatch against a plain function, a method, or a tuple struct constructor draws E0061 instead, with nearly identical wording. This guide shows the E0057 shapes, the neighboring E0061 shapes, and the repairs.

Build every program in this guide with rustc --edition 2021. In the compiler transcripts, the file names are the bare names shown on the command line.

The rule underneath: the call must match the parameter count exactly

A closure call is checked against the closure's own parameter list. There are no default values to fall back on and no second definition to try: one parameter means exactly one argument at every call, two parameters mean exactly two. The index page says the same thing in its own words: when invoking closures or other implementations of the function traits Fn, FnMut, or FnOnce using call notation, the number of parameters passed to the function must match its definition.

That is why both directions fail. Too few leaves a parameter with nothing to bind, and the body cannot run. Too many gives the extra argument nowhere to go. The compiler reports each bad call separately, so one program can draw the error once per bad call - the index example below draws it twice.

A tuple parameter does not change the count. A closure written with one parameter that happens to be a tuple pattern still takes one argument; the tuple is the argument. Calling it with the tuple's elements as separate arguments is a too-many call, and the diagnostic for that shape looks slightly different - see the tuple section below.

How to read the diagnostic

The E0057 header states both counts: this function takes 1 argument but 0 arguments were supplied, or but 2 arguments were supplied. Read those two numbers first - they tell you which side of the call to change, and by how much.

The span is on the call. For a missing argument, the marker sits after the callee and the note under it names the missing position - argument #1 is missing, or argument #2 of a named type. For an extra argument, the extra argument itself is marked as unexpected, with its type. The note below the header points back at the definition: for a direct closure call in the probed shapes it reads "closure defined here" and underlines the closure's parameter list, and for a call through a function-trait bound it reads "callable defined here" and underlines the bound.

The help line proposes the mechanical fix in the direction the counts demand. A short call gets "provide the argument," with a placeholder comment showing where it goes. A long call gets "remove the extra argument," with a diff that drops it. Both helps assume the definition is the side that is right; when the definition is the side that is wrong, the repairs below change the definition instead.

One probed shape words the diagnostic differently. When the closure takes a single tuple parameter and the call passes the elements separately, the header drops the word "this" - function takes 1 argument but 2 arguments were supplied - the note reads "closure parameter defined here," and the help offers to wrap the arguments in parentheses to construct a tuple. Same code, same rule; only the wording shifts.

The first failure: the index example

The index's erroneous example, verbatim:

Rust
#![allow(unused)]
fn main() {
let f = |x| x * 3;
let a = f();        // invalid, too few parameters
let b = f(4);       // this works!
let c = f(2, 3);    // invalid, too many parameters
}
Output
error[E0057]: this function takes 1 argument but 0 arguments were supplied
 --> fail_index.rs:4:9
  |
4 | let a = f();        // invalid, too few parameters
  |         ^-- argument #1 is missing
  |
note: closure defined here
 --> fail_index.rs:3:9
  |
3 | let f = |x| x * 3;
  |         ^^^
help: provide the argument
  |
4 | let a = f(/* x */);        // invalid, too few parameters
  |           +++++++

error[E0057]: this function takes 1 argument but 2 arguments were supplied
 --> fail_index.rs:6:9
  |
6 | let c = f(2, 3);    // invalid, too many parameters
  |         ^    - unexpected argument #2 of type `{integer}`
  |
note: closure defined here
 --> fail_index.rs:3:9
  |
3 | let f = |x| x * 3;
  |         ^^^
help: remove the extra argument
  |
6 - let c = f(2, 3);    // invalid, too many parameters
6 + let c = f(2);    // invalid, too many parameters
  |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0057`.

The example draws exactly two E0057 errors - one per bad call - and nothing for the correct call between them. The too-few error is reported on the first bad call, at fail_index.rs:4:9, and the too-many error on the second, at fail_index.rs:6:9. Each carries its own note back to the same closure definition on line 3 and its own help, so the two mistakes are repaired independently: fixing one call does not clear the other.

Each bad call on its own

Isolated, each direction draws exactly one E0057. The too-few call alone:

Rust
fn main() {
let f = |x| x * 3;
let a = f();
println!("{}", a);
}
Output
error[E0057]: this function takes 1 argument but 0 arguments were supplied
 --> fail_too_few.rs:3:9
  |
3 | let a = f();
  |         ^-- argument #1 is missing
  |
note: closure defined here
 --> fail_too_few.rs:2:9
  |
2 | let f = |x| x * 3;
  |         ^^^
help: provide the argument
  |
3 | let a = f(/* x */);
  |           +++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0057`.

And the too-many call alone:

Rust
fn main() {
let f = |x| x * 3;
let c = f(2, 3);
println!("{}", c);
}
Output
error[E0057]: this function takes 1 argument but 2 arguments were supplied
 --> fail_too_many.rs:3:9
  |
3 | let c = f(2, 3);
  |         ^    - unexpected argument #2 of type `{integer}`
  |
note: closure defined here
 --> fail_too_many.rs:2:9
  |
2 | let f = |x| x * 3;
  |         ^^^
help: remove the extra argument
  |
3 - let c = f(2, 3);
3 + let c = f(2);
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0057`.

Neither direction is a warning or a partial success: in both probed shapes the program aborts with the single error, and the value the call was meant to produce never exists.

A zero-parameter closure is the same rule at the other end. Calling a closure that takes no parameters with one argument drew exactly one E0057 in the probed shape - this function takes 0 arguments but 1 argument was supplied - with the extra argument marked unexpected and the same "remove the extra argument" help:

Rust
fn main() {
let f = || 42;
let a = f(1);
println!("{}", a);
}

The same error through the function traits

The index page's second example is a generic function bounded by Fn(): inside it, calling the parameter with no arguments is valid, and the page notes that calling it with an argument would not work. Probing that call confirms it draws E0057 - exactly one, reported on the call inside the generic function, with the note "callable defined here" pointing at the Fn() bound rather than at a closure literal:

Rust
fn foo<F: Fn()>(f: F) {
    f(3);
}
fn main() {
    foo(|| {});
}
Output
error[E0057]: this function takes 0 arguments but 1 argument was supplied
 --> fail_fn_bound.rs:2:5
  |
2 |     f(3);
  |     ^ - unexpected argument of type `{integer}`
  |
note: callable defined here
 --> fail_fn_bound.rs:1:11
  |
1 | fn foo<F: Fn()>(f: F) {
  |           ^^^^
help: remove the extra argument
  |
2 -     f(3);
2 +     f();
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0057`.

The error is reported where the mismatched call is written, inside foo - in the probed program the call site in main, which passes a closure that does satisfy the bound, draws no error of its own. The bound itself fixes the arity: an Fn() parameter takes zero arguments no matter which closure is eventually passed in, so the bad call is already wrong before any concrete closure is chosen.

The other two function traits behave the same way in the probed shapes. Under an FnMut bound that takes one argument, calling the parameter with none drew exactly one E0057 - this function takes 1 argument but 0 arguments were supplied - reported on the call inside the generic function, with the note pointing at the bound:

Rust
fn call_it<F: FnMut(i32) -> i32>(mut f: F) {
    let r = f();
    println!("{}", r);
}
fn main() {
    let mut total = 0;
    call_it(|x| { total += x; total });
}

Under an FnOnce bound that takes two arguments, calling the parameter with one drew exactly one E0057 in the probed shape - this function takes 2 arguments but 1 argument was supplied - again on the call inside the generic function, with the missing position named as argument #2.

Rust
fn call_it<F: FnOnce(i32, i32) -> i32>(f: F) {
    let r = f(1);
    println!("{}", r);
}
fn main() {
    call_it(|a, b| a + b);
}

And the bound does not need to be the empty or single-argument form. A generic function whose Fn bound fixes the arity at two, calling its parameter with one argument, drew exactly one E0057 in the probed shape, with the note pointing at the bound:

Rust
fn apply<F: Fn(i32, i32) -> i32>(f: F) -> i32 {
    f(1)
}
fn main() {
    let r = apply(|a, b| a + b);
    println!("{}", r);
}

In all four bound shapes the pattern is the same: the arity is read off the bound, the error lands on the call inside the generic function, and the concrete closure passed at the outer call site is not where the mismatch is reported.

A tuple parameter is one parameter

A closure can take a single parameter that is a tuple pattern, which lets one argument carry two values. The call still has to pass that one argument - the tuple itself. Passing the two values as separate arguments drew exactly one E0057 in the probed shape, with the reworded diagnostic described above: the header drops "this," the note reads "closure parameter defined here," and the help offers to wrap the arguments in parentheses:

Rust
fn main() {
let f = |(a, b)| a + b;
let s = f(2, 3);
println!("{}", s);
}
Output
error[E0057]: function takes 1 argument but 2 arguments were supplied
 --> fail_tuple_call.rs:3:9
  |
3 | let s = f(2, 3);
  |         ^
  |
note: closure parameter defined here
 --> fail_tuple_call.rs:2:10
  |
2 | let f = |(a, b)| a + b;
  |          ^^^^^^
help: wrap these arguments in parentheses to construct a tuple
  |
3 | let s = f((2, 3));
  |           +    +

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0057`.

The count in the header is the giveaway: the closure takes 1 argument, because the parameter list has one entry - the pattern - even though the body binds two names from it. If the diagnostic for a two-value call surprises you, count parameters in the definition, not names bound in the body.

The shapes that are not this error

The same mismatch against a regular function draws E0061, not E0057. A two-parameter function called with one argument and with three arguments in the same program drew exactly two E0061 errors in the probed shape - one per bad call, mirroring the index example's two E0057 errors:

Rust
fn add(a: i32, b: i32) -> i32 { a + b }
fn main() {
    let x = add(1);
    let y = add(1, 2, 3);
    println!("{} {}", x, y);
}
Output
error[E0061]: this function takes 2 arguments but 1 argument was supplied
 --> neighbour_e0061_fn.rs:3:13
  |
3 |     let x = add(1);
  |             ^^^--- argument #2 of type `i32` is missing
  |
note: function defined here
 --> neighbour_e0061_fn.rs:1:4
  |
1 | fn add(a: i32, b: i32) -> i32 { a + b }
  |    ^^^         ------
help: provide the argument
  |
3 |     let x = add(1, /* i32 */);
  |                  +++++++++++

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
 --> neighbour_e0061_fn.rs:4:13
  |
4 |     let y = add(1, 2, 3);
  |             ^^^       - unexpected argument #3 of type `{integer}`
  |
note: function defined here
 --> neighbour_e0061_fn.rs:1:4
  |
1 | fn add(a: i32, b: i32) -> i32 { a + b }
  |    ^^^
help: remove the extra argument
  |
4 -     let y = add(1, 2, 3);
4 +     let y = add(1, 2);
  |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0061`.

The wording is nearly identical to E0057's - the same takes/supplied counts, the same helps - and the note reads "function defined here" instead of "closure defined here." The code is decided by what is being called: a closure or a function-trait value draws E0057 in the probed shapes, and a named function draws E0061.

A method call with a missing argument is E0061 as well. Calling a one-argument method with no arguments drew exactly one E0061 in the probed shape, with the header naming it a method - this method takes 1 argument but 0 arguments were supplied - and the note reading "method defined here." The receiver does not count as the missing argument: the count in the header covers the arguments after the receiver.

Rust
struct Greeter;
impl Greeter {
    fn greet(&self, name: &str) -> String { format!("hi {}", name) }
}
fn main() {
    let g = Greeter;
    let s = g.greet();
    println!("{}", s);
}

A tuple struct constructor behaves like the function it resembles. Calling a two-field tuple struct with one argument drew exactly one E0061 in the probed shape - this struct takes 2 arguments but 1 argument was supplied - with the note reading "tuple struct defined here":

Rust
struct Pair(i32, i32);
fn main() {
    let p = Pair(1);
    println!("{}", p.0);
}

So the boundary is the kind of callable, not the shape of the mistake. Too few and too many both appear on both sides of it in the probed shapes: closures and function-trait values on the E0057 side, named functions, methods, and tuple struct constructors on the E0061 side.

Argument-count errors split by the kind of callable. For the same mismatch against a named function, a method, or a tuple struct constructor, see Wrong Argument Count E0061 Fix. For a requirement that fails outright because no impl satisfies it, see Trait Bound Not Satisfied E0277 Fix. For an impl that adds stricter requirements than the trait allows, see Impl Stricter Requirements E0276 Fix.

The repairs

Every repair below makes the call and the definition agree on one count: either the call changes to match the closure, or the closure changes so the call you want is correct.

Match the arity exactly. The index example's working middle call is the whole repair when the definition is right - pass the one argument the closure takes:

Rust
fn main() {
let f = |x| x * 3;
let b = f(4);
println!("{}", b);
}
Output
12

Widen the closure when the extra argument carries real information. If the too-many call is the call you actually want, give the closure the second parameter and use it; the widened closure compiled and ran in the probed shape, printing 9 for the same two values that failed before:

Rust
fn main() {
let f = |x, y| x * 3 + y;
let c = f(2, 3);
println!("{}", c);
}
Output
9

Give the closure a default by taking an Option. Rust closures have no default parameter values, but a single Option parameter lets each call site choose: pass None for the default, or Some value to override it. That shape compiled and ran in the probed shape, printing 3 for the default call and 12 for the explicit one:

Rust
fn main() {
let f = |x: Option<i32>| x.unwrap_or(1) * 3;
println!("{}", f(None));
println!("{}", f(Some(4)));
}
Output
3
12

Or wrap the closure in a second closure that supplies a fixed argument. The wrapper takes no parameters and calls the original with the chosen value, so callers that want the default call the wrapper and callers that want control call the original. That shape compiled and ran in the probed shape, printing 6 through the wrapper and 12 through the direct call:

Rust
fn main() {
let f = |x| x * 3;
let f_default = || f(2);
println!("{}", f_default());
println!("{}", f(4));
}
Output
6
12

Pass a tuple when the closure takes a tuple. The tuple-parameter closure from the earlier section runs when the call wraps the two values in parentheses, compiling and printing 5 in the probed shape:

Rust
fn main() {
let f = |(a, b)| a + b;
let s = f((2, 3));
println!("{}", s);
}
Output
5

For the function-trait shapes, the same choices apply one level up: change the call inside the generic function to match the bound, or change the bound to the arity the call needs - an Fn() bound becomes an Fn(i32) bound if the body must pass one argument. The bound is the definition for those calls; the concrete closures passed in then have to match the new bound instead.

Fixes in reach order

First, read the two counts in the header. In the probed shapes they name exactly what is wrong: takes 1 but 0 supplied for the too-few calls (the index example's first call, the isolated too-few call, the FnMut shape), takes 1 but 2 supplied for the too-many calls (the index example's second call, the isolated too-many call), takes 0 but 1 supplied for the zero-parameter closure and the Fn() shape, and takes 2 but 1 supplied for the FnOnce shape and the Fn bound fixing the arity at two.

Second, note which note the diagnostic carries, because it tells you what you called. In the probed shapes, "closure defined here" marks a direct closure call, "callable defined here" marks a call through a function-trait bound - reported inside the generic function, not at the outer call site - "closure parameter defined here" marks the tuple-parameter shape, and the E0061 notes - "function defined here," "method defined here," "tuple struct defined here" - mark the neighboring shapes that carry the other code.

Third, decide which side is wrong before editing. If the definition expresses what the code needs, follow the help: provide the missing argument, or remove the extra one. In the probed repairs, matching the arity exactly compiled and printed 12. If the call expresses what the code needs, change the definition instead: widen the closure, take an Option, wrap it, or pass a tuple - all four compiled and ran in the probed shapes.

Fourth, count errors per call, not per program. The index example drew two E0057 errors for two bad calls with a correct call between them, and the regular-function shape drew two E0061 errors the same way. Fixing the first reported call leaves the second one standing; work through the list until the program compiles.

Last, leave the working shapes alone: a call whose count matches its closure's parameter count compiles in the probed shapes, on both sides of the E0057/E0061 boundary. Do not renumber a working call while fixing the broken one next to it.

Decision summary

E0057 fired for every wrong-count closure or function-trait call probed: the index example (exactly two E0057 errors, one for the too-few call at the first bad call and one for the too-many call at the second, with the correct call between them drawing nothing), each bad call isolated (exactly one E0057 each), a zero-parameter closure called with one argument (exactly one E0057), a generic function bounded by Fn() calling its parameter with an argument (exactly one E0057, reported on the call inside the generic function, with the note pointing at the bound), the same mismatch under FnMut and FnOnce bounds (exactly one E0057 each, on the call inside the generic function), a call falling one short of an Fn bound that fixes the arity at two (exactly one E0057), and a tuple-parameter closure called with two separate arguments (exactly one E0057, with the reworded header, the "closure parameter defined here" note, and the wrap-in-parentheses help). It did not fire for a regular function called with too few and too many arguments (exactly two E0061 errors in the probed shape), a method called with a missing argument (exactly one E0061), or a tuple struct constructor called with a missing argument (exactly one E0061). The shapes that compiled and ran were the exact-arity call (printing 12), the widened two-parameter closure (printing 9), the Option parameter with a default inside (printing 3 for None and 12 for Some(4)), the wrapper closure supplying a fixed argument (printing 6 through the wrapper and 12 directly), and the tuple-parameter closure called with a tuple (printing 5).

Checklist

  • Count both sides: in the probed shapes, E0057 fires when the number of arguments supplied differs from the number of parameters the closure - or the Fn, FnMut, or FnOnce bound - defines, in either direction.
  • One error per bad call: the index example drew two E0057 errors for its two bad calls in the probed shape, and the correct call between them drew nothing - clear the errors one call at a time.
  • The note names the callable: "closure defined here" for a direct closure call, "callable defined here" for a call through a function-trait bound, and "closure parameter defined here" for the tuple-parameter shape, in the probed shapes.
  • Bound shapes report inside the generic function: in the probed Fn, FnMut, and FnOnce shapes, the error lands on the call inside the generic function and the outer call site that passes the closure draws no error of its own.
  • A tuple parameter counts as one: a closure with one tuple-pattern parameter takes one argument in the probed shape, and passing the elements separately is a too-many call whose help offers to wrap them in parentheses.
  • The same mistake against a named function, a method, or a tuple struct constructor is E0061, not E0057, in the probed shapes - with nearly identical wording and "function defined here," "method defined here," or "tuple struct defined here" in the note.
  • The repairs in the probed shapes: match the arity exactly, widen the closure to the parameter count the call needs, take an Option and supply the default inside, wrap the closure in a second closure that supplies a fixed argument, or pass a tuple to a tuple-parameter closure.

Sources

  • Rust error codes index, E0057 - an invalid number of arguments was given when calling a closure; the erroneous example is a one-parameter closure called with no argument and with two arguments; the page states that when invoking closures or other implementations of the function traits Fn, FnMut or FnOnce using call notation, the number of parameters passed must match the definition, and its second example is a generic function bounded by Fn() whose parameter must be called with no arguments.
  • Rust error codes index, E0061 - an incorrect number of arguments was passed when calling a function; the code drawn in the probed shapes by a regular function called with too few and too many arguments, a method called with a missing argument, and a tuple struct constructor called with a missing argument.

Keep Exploring