Email me

Rust errors / Everything else

Rust compiler error · checked with rustc 1.99.0

Rust error E0061: this function takes N arguments but M were supplied

What it meansA function or method was called with the wrong number of arguments.

What rustc prints

error[E0061]: this function takes 1 argument but 0 arguments were supplied
 --> main.rs:5:1
  |
5 | f(); // error!
  | ^-- argument #1 of type `i32` is missing
  |
note: function defined here
 --> main.rs:3:4
  |
3 | fn f(u: i32) {}
  |    ^ ------
help: provide the argument
  |
5 | f(/* i32 */); // error!
  |   +++++++++

Real output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.

Why it happens

  • A crate update changed a function signature.
  • Forgetting that a method needs an argument (or passing one it does not take).

How to fix it

1. Match the signature

Hover in your editor or read the help line; it lists the expected parameters.

fn area(w: f64, h: f64) -> f64 { w * h }
let a = area(3.0, 4.0);

Other wordings of this error

this function takes N arguments but M were supplied, this function takes arguments but were supplied, this method takes arguments but, argument missing, unexpected argument

E0061Everything else
Activein rustc 1.99.0
8related errors linked below

The compiler team's explanation

An invalid number of arguments was passed when calling a function.

Erroneous code example:

fn f(u: i32) {}

f(); // error!

The number of arguments passed to a function must match the number of arguments specified in the function signature.

For example, a function like:

fn f(a: u16, b: &str) {}

Must always be called with exactly two arguments, e.g., f(2, "test").

Note that Rust does not have a notion of optional function arguments or variadic functions (except for its C-FFI).

From rustc --explain E0061 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.

Related errors

All 518 Rust error codes · Rust crate data · Glossary

Up next

Often hit nextE0412: cannot find type in this scopeA related error from the same family.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ