Rust
E0424 Self Used Without a Receiver Fix
self is not a variable that happens to be in scope. It exists only inside a method, and a method is an associated function whose first parameter is a receiver. This guide works the shapes that draw E0424 - a method call, a field read, a field write, a trait default, a free function, and a return of self itself - and matches each one to the repair its body actually needs: the right receiver, an ordinary parameter, or a value built on the spot.
Written November 29, 2026 · Tested with Rust 1.99.1 · 22 min read
- The rule underneath: a receiver is the only source of self
- How to read the diagnostic
- The first failure: an associated function calls a method on self
- The second failure: an associated function reads a field
Written November 29, 2026
Tested with Rust 1.99.1
What this guide is
Error E0424 is self used where no self exists. The error codes index states the rule in one sentence: "The self keyword was used inside of an associated function without a self receiver parameter." Its example is a struct with two functions in one impl block: bar, which takes &self and is therefore a method, and foo, which takes no receiver and is therefore only an associated function, calling self.bar() in its body. That call is the error. Inside foo there is no instance for self to name, because nothing passed one in.
The distinction the error enforces is between a method and an associated function. Both live in an impl or trait block. A method is the one whose first parameter is a receiver - self, &self, &mut self, or a typed form such as self: Box<Self>. An associated function has any other parameter list, or none, and is called on the type itself, as Foo::baz(), with no instance in hand. A free function and a nested function are further out still: the diagnostic for those says the function "can't have a self parameter" at all. In every case the body was written as if an instance were available, and the repair is to make one available in the way the body needs, or to stop asking for one.
The forms in this guide each reproduce E0424 with a small, complete program: an associated function calling another method on self, one reading a field, one writing a field, a trait default method, a free function, and an associated function returning self as its result. Each failure is followed by its repair. The repairs look alike - most add a receiver - but they are not interchangeable: a body that writes a field needs &mut self, a body that only reads can take &self, and two of the six shapes cannot take a receiver at all and are repaired by changing what the function receives or returns instead.
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: a receiver is the only source of self
A receiver is a parameter like any other, with one special property: it binds the keyword self in the body and it decides how the function is called. With a receiver, the call is instance.method() and the instance arrives as self. Without one, the call is Type::function() and the body starts with only its named parameters in scope. Writing self in that body is writing the name of a value nobody supplied, which is why the diagnostic's header is the plain "cannot find value self in this scope" rather than a complaint about the call site.
That framing decides the repair before any code changes. Read the body and ask what it does with self. If it only reads - calls a &self method, reads a field - a shared receiver supplies it. If it writes a field, the receiver must be mutable. If it consumes or returns the instance, the receiver must be by value. If the function is meant to stay callable on the type, with no instance - a constructor, a constant-like helper - then self is the wrong tool and the body should work from an ordinary parameter or from values it builds itself. The compiler's help line always proposes &self; as the traps show, that proposal is the right answer only for the reading shapes.
How to read the diagnostic
The header is "cannot find value self in this scope", with the code E0424. The caret span sits under the self use itself, and it carries two labels: "self value is a keyword only available in methods with a self parameter" under the use, and "this function doesn't have a self parameter" under the function name. Where a receiver is possible, a help block then proposes one, spelling the changed signature out in full - fn baz(&self) -> i32 for the first failure below. Where no receiver is possible, the second label changes instead: a free function and a nested function are told "this function can't have a self parameter", and no help block follows. That wording difference is the fastest tell in the whole error: "doesn't have" invites a receiver, "can't have" demands a parameter or a redesign.
Two counting facts are worth knowing before the failures. The error fires once per use, not once per function: a body that writes self.value + self.value in a receiver-less function draws the same E0424 twice, once under each self, and both clear together when the receiver is added. And the note under every span - "a module named self exists in another namespace" - is a red herring for this error; it records that self also names a module path, which is a different use of the word, worked in the traps.
The first failure: an associated function calls a method on self
This is the error index's own shape, given a caller. bar is a method; baz is an associated function whose body calls self.bar():
struct Foo { value: i32 }
impl Foo {
fn bar(&self) -> i32 { self.value }
fn baz() -> i32 { self.bar() }
}
fn main() { let f = Foo { value: 7 }; println!("baz is {}", Foo::baz()); }
error[E0424]: cannot find value `self` in this scope
--> a1.rs:4:23
|
4 | fn baz() -> i32 { self.bar() }
| --- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function doesn't have a `self` parameter
|
= note: a module named `self` exists in another namespace
help: add a `self` receiver parameter to make the associated `fn` a method
|
4 | fn baz(&self) -> i32 { self.bar() }
| +++++
warning: unused variable: `f`
--> a1.rs:6:17
|
6 | fn main() { let f = Foo { value: 7 }; println!("baz is {}", Foo::baz()); }
| ^ help: if this is intentional, prefix it with an underscore: `_f`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0424`.
The span names both ends: baz doesn't have a self parameter, and the self in its body is a keyword only available in methods. The repair the compiler proposes is the repair that works here, because the body only reads: give baz a shared receiver, and call it on an instance:
struct Foo { value: i32 }
impl Foo {
fn bar(&self) -> i32 { self.value }
fn baz(&self) -> i32 { self.bar() }
}
fn main() { let f = Foo { value: 7 }; println!("baz is {}", f.baz()); }
baz is 7
The output is baz is 7: the instance the caller already had now flows into baz as self, and the inner call resolves. Where baz must stay an associated function - called on the type, with the instance passed explicitly - the same body works with an ordinary parameter instead, and no self appears in it:
struct Foo { value: i32 }
impl Foo {
fn bar(&self) -> i32 { self.value }
fn baz(f: &Foo) -> i32 { f.bar() }
}
fn main() { let f = Foo { value: 7 }; println!("baz is {}", Foo::baz(&f)); }
baz is 7
The output is again baz is 7. The two repairs are the fork this error always presents: make the function a method and let the receiver carry the instance, or keep it an associated function and carry the instance in a named parameter. The body's needs decide; the call sites follow.
The second failure: an associated function reads a field
A field read is the same defect in smaller form. current has no receiver, and its body reads self.count:
struct Counter { count: i32 }
impl Counter {
fn current() -> i32 { self.count }
}
fn main() { let c = Counter { count: 3 }; println!("{}", Counter::current()); }
error[E0424]: cannot find value `self` in this scope
--> a3.rs:3:27
|
3 | fn current() -> i32 { self.count }
| ------- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function doesn't have a `self` parameter
|
= note: a module named `self` exists in another namespace
help: add a `self` receiver parameter to make the associated `fn` a method
|
3 | fn current(&self) -> i32 { self.count }
| +++++
warning: unused variable: `c`
--> a3.rs:5:17
|
5 | fn main() { let c = Counter { count: 3 }; println!("{}", Counter::current()); }
| ^ help: if this is intentional, prefix it with an underscore: `_c`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0424`.
Nothing here mutates, so the shared receiver the compiler proposes is sufficient, and the call moves from the type to the instance:
struct Counter { count: i32 }
impl Counter {
fn current(&self) -> i32 { self.count }
}
fn main() { let c = Counter { count: 3 }; println!("{}", c.current()); }
3
The output is 3, the count the caller stored. A field read and a method call draw the identical diagnostic and take the identical repair, because both are reads of a value the function was never given.
The third failure: an associated function writes a field
A write raises the stakes on the receiver's form. bump has no receiver, and its body increments self.count:
struct Counter { count: i32 }
impl Counter {
fn bump() { self.count += 1; }
}
fn main() { Counter::bump(); }
error[E0424]: cannot find value `self` in this scope
--> a4.rs:3:17
|
3 | fn bump() { self.count += 1; }
| ---- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function doesn't have a `self` parameter
|
= note: a module named `self` exists in another namespace
help: add a `self` receiver parameter to make the associated `fn` a method
|
3 | fn bump(&self) { self.count += 1; }
| +++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
The compiler's help proposes &self here too - and for this body that proposal is a trap, worked below: a shared receiver supplies a self but not a writable one. The repair this body needs is a mutable receiver:
struct Counter { count: i32 }
impl Counter {
fn bump(&mut self) { self.count += 1; }
}
fn main() { let mut c = Counter { count: 3 }; c.bump(); println!("{}", c.count); }
4
The output is 4: the counter starts at 3, bump runs on the mutable instance, and the caller's own read afterward shows the increment. Read the body's use of self before accepting any suggested receiver - a read takes &self, a write takes &mut self, and the difference is not visible in the E0424 span itself.
The fourth failure: a trait default method without a receiver
Trait default methods follow the same rule as impl methods. greet is given a default body in the trait, the body uses self.name(), and the signature carries no receiver:
trait Greeter {
fn name(&self) -> &str;
fn greet() -> String { format!("hello {}", self.name()) }
}
struct Ann;
impl Greeter for Ann { fn name(&self) -> &str { "Ann" } }
fn main() { println!("{}", Ann::greet()); }
error[E0424]: cannot find value `self` in this scope
--> a5.rs:3:48
|
3 | fn greet() -> String { format!("hello {}", self.name()) }
| ----- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function doesn't have a `self` parameter
|
= note: a module named `self` exists in another namespace
help: add a `self` receiver parameter to make the associated `fn` a method
|
3 | fn greet(&self) -> String { format!("hello {}", self.name()) }
| +++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
The repair is in the trait, not in any implementation: add the shared receiver to the default method's signature, and every implementor's call becomes a method call:
trait Greeter {
fn name(&self) -> &str;
fn greet(&self) -> String { format!("hello {}", self.name()) }
}
struct Ann;
impl Greeter for Ann { fn name(&self) -> &str { "Ann" } }
fn main() { println!("{}", Ann.greet()); }
hello Ann
The output is hello Ann. A default body is still a body, and it has exactly the self its signature declares - no more. Implementors that override greet declare their own receivers in the usual way; the default's signature binds only the default body.
The fifth failure: a free function uses self
Outside an impl or trait block there is no receiver to add. This free function's body reads self.value, and its diagnostic says so plainly:
struct Foo { value: i32 }
fn show() -> i32 { self.value }
fn main() { println!("hi"); }
error[E0424]: cannot find value `self` in this scope
--> a2.rs:2:20
|
2 | fn show() -> i32 { self.value }
| ---- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function can't have a `self` parameter
|
= note: a module named `self` exists in another namespace
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
The second label is the changed wording: "this function can't have a self parameter", and no help block follows. The repair passes the value in as an ordinary parameter and reads the field through its name:
struct Foo { value: i32 }
fn show(f: &Foo) -> i32 { f.value }
fn main() { let f = Foo { value: 9 }; println!("{}", show(&f)); }
9
The output is 9. A free function that needs an instance's data takes the instance - or the field it needs - as a parameter. Moving the function into an impl block and giving it a receiver is the other honest repair; what cannot be done is leave it where it is and have self mean anything.
The sixth failure: an associated function returns self
Here self is not read or written but returned, as if the associated function were handing back the instance it was called on - except it was called on the type, and there is no instance:
#[derive(Debug)]
struct Point { x: i32, y: i32 }
impl Point {
fn origin() -> Point { self }
}
fn main() { println!("{:?}", Point::origin()); }
error[E0424]: cannot find value `self` in this scope
--> a6.rs:4:28
|
4 | fn origin() -> Point { self }
| ------ ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function doesn't have a `self` parameter
|
= note: a module named `self` exists in another namespace
help: add a `self` receiver parameter to make the associated `fn` a method
|
4 | fn origin(&self) -> Point { self }
| +++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
The compiler proposes &self, and that proposal fails twice over, as the traps show: the return type is the owned Point, and a shared receiver would supply only a &Point. This shape's real question is what the function was meant to produce. If it is a constructor - and a function named origin returning a Point is one - the repair builds the value:
#[derive(Debug)]
struct Point { x: i32, y: i32 }
impl Point {
fn origin() -> Point { Point { x: 0, y: 0 } }
}
fn main() { println!("{:?}", Point::origin()); }
Point { x: 0, y: 0 }
The output is Point { x: 0, y: 0 }. If instead the intent was to hand an existing instance back unchanged, that is a by-value method under an honest name:
#[derive(Debug)]
struct Point { x: i32, y: i32 }
impl Point {
fn itself(self) -> Point { self }
}
fn main() { let p = Point { x: 1, y: 2 }; println!("{:?}", p.itself()); }
Point { x: 1, y: 2 }
The output is Point { x: 1, y: 2 }, the instance the caller passed in. Either repair removes self from a function that never receives one, or gives the function the by-value receiver that makes self the value being returned.
The traps
An associated constant cannot take a receiver at all. Its initializer runs with no instance in existence, and the diagnostic for it carries a different second label - "self not allowed in an implementation":
struct Foo { value: i32 }
impl Foo {
const DEFAULT_VALUE: i32 = self.value;
}
fn main() { println!("{}", Foo::DEFAULT_VALUE); }
error[E0424]: cannot find value `self` in this scope
--> a7.rs:3:32
|
2 | / impl Foo {
3 | | const DEFAULT_VALUE: i32 = self.value;
| | ^^^^ `self` value is a keyword only available in methods with a `self` parameter
4 | | }
| |_- `self` not allowed in an implementation
|
= note: a module named `self` exists in another namespace
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
The repair gives the constant a value that does not depend on an instance:
struct Foo { value: i32 }
impl Foo {
const DEFAULT_VALUE: i32 = 0;
}
fn main() { println!("{}", Foo::DEFAULT_VALUE); }
0
The output is 0. A per-instance default does not belong in an associated constant; it belongs in a constructor or a Default implementation, where a value is being built.
A closure does not rescue self either. Wrapping the call in a closure inside the same receiver-less function changes nothing, because the closure captures from the function's own scope, and that scope has no self:
struct Foo { value: i32 }
impl Foo {
fn bar(&self) -> i32 { self.value }
fn baz() -> i32 { let f = || self.bar(); f() }
}
fn main() { println!("{}", Foo::baz()); }
error[E0424]: cannot find value `self` in this scope
--> a8.rs:4:34
|
4 | fn baz() -> i32 { let f = || self.bar(); f() }
| --- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function doesn't have a `self` parameter
|
= note: a module named `self` exists in another namespace
help: add a `self` receiver parameter to make the associated `fn` a method
|
4 | fn baz(&self) -> i32 { let f = || self.bar(); f() }
| +++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
With the receiver added to the outer function, the same closure compiles, because now there is a self for it to capture:
struct Foo { value: i32 }
impl Foo {
fn bar(&self) -> i32 { self.value }
fn baz(&self) -> i32 { let f = || self.bar(); f() }
}
fn main() { let f = Foo { value: 11 }; println!("{}", f.baz()); }
11
The output is 11. Closures capture the scope they are written in; they do not create the values they capture.
A nested function is a free function for this purpose. It is defined inside a method's body, but it has its own parameter list, captures nothing from the enclosing body, and its diagnostic carries the "can't have" wording:
struct Foo { value: i32 }
impl Foo {
fn make() -> Foo {
fn inner() -> i32 { self.value }
Foo { value: inner() }
}
}
fn main() { println!("{}", Foo::make().value); }
error[E0424]: cannot find value `self` in this scope
--> a9.rs:4:29
|
4 | fn inner() -> i32 { self.value }
| ----- ^^^^ `self` value is a keyword only available in methods with a `self` parameter
| |
| this function can't have a `self` parameter
|
= note: a module named `self` exists in another namespace
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0424`.
The repair passes what the nested function needs as its own parameter, supplied by the enclosing function:
struct Foo { value: i32 }
impl Foo {
fn make(value: i32) -> Foo {
fn inner(v: i32) -> i32 { v }
Foo { value: inner(value) }
}
}
fn main() { println!("{}", Foo::make(13).value); }
13
The output is 13. A nested function that needs the enclosing value takes it as an argument at the call - the enclosing self, where the enclosing function has one, included.
Following the compiler's &self suggestion literally on the third failure trades one error for another. The receiver now exists, so E0424 clears, and the write itself is refused:
error[E0594]: cannot assign to `self.count`, which is behind a `&` reference
--> b1.rs:3:22
|
3 | fn bump(&self) { self.count += 1; }
| ^^^^^^^^^^^^^^^ `self` is a `&` reference, so it cannot be written to
|
help: consider changing this to be a mutable reference
|
3 | fn bump(&mut self) { self.count += 1; }
| +++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0594`.
That is E0594, "cannot assign to self.count, which is behind a & reference", and its own help points at the mutable receiver the body needed from the start. The suggestion on the sixth failure misleads differently: adding &self to a function that returns self as an owned value draws a type mismatch - expected Point, found &Point - together with an arity error at the old call site, because the function now takes an argument the call does not supply. In both cases the suggestion is a starting point that assumes a reading body; check it against the body before applying it.
Capital Self is a different word. It names the type, not an instance, and it is available in associated functions with no receiver at all - the standard constructor shape compiles as it stands:
struct Foo { value: i32 }
impl Foo {
fn new(value: i32) -> Self { Self { value } }
}
fn main() { let f = Foo::new(5); println!("{}", f.value); }
5
The output is 5. Using that type name where a value is needed is not E0424: Self.value in a method body draws an un-coded error stating that the Self constructor can only be used with tuple or unit structs. And the module-path use of the word is different again: self::thing() inside an impl block, aimed at an associated function of the same type, draws E0425, "cannot find function thing in module self" - the path self names the current module, not the current type, whose functions are reached as Self::thing() or through an instance. Three spellings that look alike - self, Self, self:: - name a value, a type, and a module, and only the first is this error.
The controls confirm the boundary from the other side. A method with a shared receiver that reads a field compiles (the second failure's repair). A by-value receiver compiles and consumes the instance. A typed receiver compiles too - a method taking self: Box<Self> and reading a field through it:
struct Foo { value: i32 }
impl Foo { fn boxed(self: Box<Self>) -> i32 { self.value } }
fn main() { let f = Box::new(Foo { value: 21 }); println!("{}", f.boxed()); }
21
The output is 21. Any receiver form binds self; no parameter list without one does, whatever block the function sits in.
Fixes in reach order
When E0424 appears, work the body in this order. First, read what the body does with self and add the receiver that matches: &self for reads and method calls, &mut self for field writes, self by value when the body consumes or returns the instance, and call the function on an instance from then on. Second, where the function must stay callable on the type, replace self with an ordinary parameter of the type and pass the instance at the call. Third, where the shape cannot take a receiver - a free function, a nested function, an associated constant - pass the needed value in as a parameter, or, for a constant or a constructor, build the value from literals and parameters instead of reading it from an instance. Fourth, where the body returns self, decide whether it is a constructor (build the value) or an identity method (take self by value under a name that says so). Last, check the spelling: a body that needs the type - a constructor returning Self, a call to Self::function() - may have written the value word where the type word belongs, and that fix is one capital letter.
Decision summary
self exists only where a receiver binds it: a method in an impl or trait block whose first parameter is self, &self, &mut self, or a typed receiver. Every other function - an associated function, a trait default without a receiver, a free function, a nested function, a closure written in any of those, an associated constant - has no self to use, and each use draws one E0424. The receiver the body needs is set by what the body does: shared for reads, mutable for writes, by value for consumption and return. The compiler's suggested &self is correct for reading bodies and a way station for writing or returning ones, where it clears E0424 and immediately draws the next error. Where no receiver is possible, the instance, or the field, or the finished value, travels as an ordinary parameter or is built on the spot. Self and self:: are not variants of the same mistake: one is the type and is legal in exactly the functions this error is about, the other is a module path and fails under a different code.
Checklist
- The function using
selfhas a receiver as its first parameter -self,&self,&mut self, or a typed form such asself: Box<Self>. - The receiver matches the body: shared for reads, mutable for field writes, by value when the instance is consumed or returned.
- The call site matches the new form:
instance.method()for a method, notType::function(). - A function that stays associated takes the instance, or the field it needs, as a named parameter, and its body uses that name.
- Free functions, nested functions, and closures use only their own parameters - nothing is captured or inherited from an enclosing body.
- Associated constants and constructors build their values; neither reads a field from an instance that does not exist yet.
- Each
selfuse in the body was counted: the error fires once per use, and a fix is complete only when every use compiles. self,Self, andself::are spelled for the thing each names: the instance, the type, the module.
Related guides on this site
- Fix Rust E0596 "cannot borrow as mutable" — a Vec Without mut, a Function Taking &Vec, a &self Method Pushing to a Field, and a Shared Reference in a Binding
- E0185 Method Has Self but Trait Does Not Fix
- E0186 Method Lacks Self but Trait Has It Fix
- E0069 Return Without Value Fix
Sources
- Rust error codes index, E0424 -
selfused in an associated function without aselfreceiver, the index'sbar/fooexample, the receiver forms it lists, and its prescription to add a receiver where the function should be a method. - The Rust Programming Language, Method Syntax - methods are functions defined in an
implblock whose first parameter isself, the receiver forms&self,&mut self, andselfby value, and associated functions as theimplfunctions without one, called on the type. - The Rust Programming Language, Traits - default method implementations in a trait, and method signatures carrying their receivers.
- Rust error codes index, E0594 - a non-mutable value was assigned a value; the code the mutating third failure draws, as "cannot assign to
self.count, which is behind a&reference", when it is given the shared receiver the E0424 help suggests. - Rust error codes index, E0425 - a name not found in a scope or module, the code the
self::path form of the mistake draws.
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.