Rust E0061: this function takes 1 argument but 2 were supplied
E0061 counts arguments at the call site. Check the signature, method versus associated function, generic defaults, and trait impls that changed arity.

Introduction & Quick Summary
A call that looks right is rejected by arity:
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> src/main.rs:9:5
|
9 | calculate(value, rate);
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: function defined here
--> src/lib.rs:3:8
|
3 | pub fn calculate(value: f64) -> f64 {
| ^^^^^^^^^ -----------
help: remove the extra argument
|
9 - calculate(value, rate);
9 + calculate(value);Quick answer: the call site and the definition disagree about how many arguments the function takes. E0061 is deliberately literal — it counts arguments and tells you which one to remove — so the fix starts by reading the note: block, which points at the definition the compiler actually resolved.
fn calculate(value: f64) -> f64 { value * 2.0 }
fn main() {
let value = 3.0;
let rate = 0.2;
calculate(value); // fix: match the signature
}The interesting cases are the ones where the count is not what it seems: a method call that supplies self, an associated function called with ::, a trait method with a different arity than an inherent one, a tuple-struct constructor, a macro that expands to a function, or a signature that changed because a cfg feature is off. This guide covers each, plus the Rust patterns for optional arguments, which do not exist in the language and must be modelled.
Core Mechanics, Signatures & Reproducible Setup
A Rust function's signature fixes its arity exactly. There are no default parameters, no keyword arguments, and no overloads: two functions with the same name in one scope are a compile error. Variadic calls exist only in FFI (extern "C" with ...) and are unsafe to call.
fn area(width: f64, height: f64) -> f64 { width * height }
struct Rect { w: f64, h: f64 }
impl Rect {
fn new(w: f64, h: f64) -> Self { Rect { w, h } } // 2 args, associated
fn area(&self) -> f64 { self.w * self.h } // 1 arg: &self
fn scaled(&self, factor: f64) -> f64 { self.area() * factor } // 2: &self, factor
}
fn main() {
let r = Rect::new(2.0, 3.0); // associated function
let _ = r.area(); // method: receiver is implicit
let _ = r.scaled(1.5);
let _ = Rect::new(2.0); // E0061: 1 supplied, 2 expected
}Three call forms have different arities for the same underlying code:
| Call form | What is supplied |
|---|---|
f(a, b) | exactly the parameters |
Type::f(&x, a) | self explicitly, plus parameters |
x.f(a) | self implicitly, plus parameters |
A reproducible file with the failure modes:
cargo new e0061 && cd e0061
cat > src/main.rs <<'RS'
fn greet(name: &str, times: u8) -> String { name.repeat(times as usize) }
fn main() {
let s = greet("hi");
println!("{s}");
}
RS
cargo build 2>&1 | head -12The compiler prints the definition, the call, and a suggestion. In a workspace, the note: block is the important part: with several similarly named functions, it names the one the compiler resolved, which is often not the one you were reading.
Key Comparison Table
| Message | Likely cause | Fix |
|---|---|---|
| takes 1 argument but 2 were supplied | extra argument, or a parameter was removed | delete the argument, or restore the parameter |
| takes 2 arguments but 1 was supplied | missing argument | supply it, or use the builder |
| takes 0 arguments but 1 was supplied | calling with self a function without one | use Type::f(x) or drop the receiver |
| this method takes 1 argument but 0 were supplied | called as a method instead of a function | Type::method(&value) |
expected &str, found String (E0308) | right count, wrong type | convert with &s or s.as_str() |
| Situation | Why the count differs | Correct call |
|---|---|---|
| inherent method | &self is implicit | value.method(arg) |
| associated function | no receiver at all | Type::new(arg) |
| trait method in scope | same name, different trait | qualify: Trait::method(&value, arg) |
| tuple struct constructor | constructor is a function | Point(x, y) |
| enum variant with fields | variant is a function | Shape::Circle(r) |
| function pointer variable | type includes the arity | let f: fn(i32) -> i32 = double; |
| Optional-argument need | Idiomatic Rust | Cost |
|---|---|---|
| one optional value | Option<T> parameter | call site passes None |
| many optional values | builder pattern | boilerplate, clear call sites |
| config object | struct with Default | one struct type |
| variadic values | slice or IntoIterator | callers pass &[..] |
| no-argument case | second function (f, f_default) | name explosion |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Method versus associated function
String::from has no receiver; to_string does. Mixing them produces E0061 with a receiver counted as an argument:
let a = String::from("x"); // associated: 1 arg
let b = "x".to_string(); // method: 0 args, receiver implicit
let c = String::to_string("x"); // E0061: to_string expects &self as the only argThe last line is legal with the explicit-receiver form String::to_string(&"x".to_string()); it is written here to show what the compiler counts.
2. Trait methods with the same name
Two traits can define the same method with different arities. A call resolves by what is in scope, and an use change can break a working call:
trait Render { fn render(&self) -> String; }
trait RenderWith { fn render(&self, width: usize) -> String; }
impl Render for Doc { fn render(&self) -> String { String::new() } }
impl RenderWith for Doc { fn render(&self, _w: usize) -> String { String::new() } }
let d = Doc::default();
let _ = d.render(); // ambiguous if both are in scope (E0034) ...
let _ = Render::render(&d); // qualified: unambiguous
let _ = RenderWith::render(&d, 80);When the compiler picks one, the other call site fails with E0061 rather than E0034 — the note: block names which trait it resolved.
3. Constructors, variants and closures
Tuple structs and enum variants are functions, so a wrong field count is E0061:
struct Point(f64, f64);
enum Shape { Circle(f64), Rect(f64, f64) }
let p = Point(1.0, 2.0);
let c = Shape::Circle(1.0);
let r = Shape::Rect(1.0); // E0061: 2 fields expectedClosures infer their arity from the call, and passing a closure where a fn pointer is expected fixes it:
let double = |x: i32| x * 2; // Fn(i32) -> i32
fn apply(f: fn(i32) -> i32, v: i32) -> i32 { f(v) }
let _ = apply(double, 4);4. Macros that expand to functions
A macro error can surface as E0061 in the expansion, with a span pointing at your macro call:
println!("{} {}", 1); // E0061 inside format_args!
format!("{name}"); // needs a `name` variable or a positional argument
vec![0; ]; // wrong arity inside vec!cargo expand (nightly or a cargo subcommand install) shows the expanded code when the span is not enough, and --message-format=short keeps the output readable.
5. Signatures changed by cfg or by a version bump
A parameter that only exists with a feature enabled changes the arity depending on how the crate is compiled:
#[cfg(feature = "tls")]
pub fn connect(host: &str, port: u16, cert: &Path) -> Result<Conn, Error> { ... }
#[cfg(not(feature = "tls"))]
pub fn connect(host: &str, port: u16) -> Result<Conn, Error> { ... }The call that supplies three arguments fails in a build where the feature is off. Check the feature set before editing the call (cargo tree -e features), and prefer an options struct so the signature does not depend on a cfg.
6. Optional arguments without default parameters
Rust has no default arguments, so a port from a language that does ends up adding an argument that the definition does not take, or removing one it requires. Model the optionality:
pub struct Config { pub retries: u8, pub timeout_ms: u64 }
impl Default for Config {
fn default() -> Self { Self { retries: 3, timeout_ms: 1_000 } }
}
pub fn fetch(url: &str, cfg: &Config) -> Result<Vec<u8>, Error> { ... }
// call site
fetch("https://example.com", &Config::default())?;
fetch("https://example.com", &Config { retries: 0, ..Default::default() })?;The struct keeps the arity at two and makes new options additive rather than breaking.
The text diff tool is useful when a signature changed between two commits and the call sites were not updated, and the regular expression tester pulls every E0061 location out of a long cargo build --message-format=short log.
Common Compilation/Runtime Mistakes & Version Gotchas
- Adding
_to "use up" an argument.fn f(a, _b)changes the API for every caller; remove the parameter instead. - Calling a method as a function.
Type::method(x)is correct,Type::method(x, y)is not: the receiver is the first argument. - Assuming
&selfis optional. It is a parameter in the signature and the first argument in the explicit form. - Copying a signature from an older version's docs. Standard library functions do change; the compiler's
note:block shows the version you actually link against. - Overloading by adding a generic parameter type. Two
implblocks with different trait bounds can look like overloads but resolve to one function at the call site. - Mixing
fnpointers and closures. A closure that captures requiresimpl Fn; passing it wherefnis expected changes the expected type, not the arity. - Edition 2024
genkeyword and unsafe attributes. Unrelated to arity, but a rename that shadows a function name produces "cannot find function" or a different E-code and can be mistaken for a signature problem.
Official documentation: E0061 error index and Functions in the Rust Book.
Official references
primary documentationThe Rust documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Rust work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Rust guides
All Rust guidesRust E0282: type annotations needed
E0282 means inference ran out of information. Annotate the binding, add a turbofish to collect or parse, or fix the signature the value flows into.
Rust E0463: can't find crate for std
The target triple has no standard library installed. Add the target with rustup, check the target string and link the right ABI.
Rust E0432: unresolved import
E0432 is a module graph problem: a missing mod declaration, a private parent or a wrong path. Fix the tree, not the dependency list.
Rust E0106: missing lifetime specifier
E0106 appears when a returned borrow has no input to borrow from. Name the lifetime in functions, structs and impls, or return owned data.
More in Rust
All Rust guidesThe guides filed next to this one in Rust, in library order.