Rust

E0307 Invalid Self Parameter Fix

E0307 is the compiler refusing a method receiver that does not lead back to the type the method is implemented on: self: &Bar on an impl for Foo, self: i32, self: String, or a wrapper around the wrong type. The diagnostic states the rule in one note - the type of self must be Self or a type that dereferences to it - and lists the receiver forms that satisfy it. This guide shows the error on the shapes that draw it, the legal forms running, and the boundary around the code: the concrete type name works as well as Self, a Pin around the wrong type still fails, and a missing receiver at a call site is a different error entirely.

Written December 1, 2026 · Tested with Rust 1.99.1 · 15 min read

By the end of this guide
  • The rule underneath: the receiver must lead back to the implementing type
  • How to read the diagnostic
  • The first failure: a reference to the wrong type
  • The same error across the wrong shapes

Written December 1, 2026

Tested with Rust 1.99.1

What this guide is

Error E0307 is about the type written on a method's first parameter. The error codes index opens: "The self parameter in a method has an invalid receiver type." Its erroneous example implements a trait for Foo but declares the method as fn foo(self: &Bar), naming a different struct as the receiver - and a receiver that is not the implementing type is not a receiver at all.

The practical payoff is that the diagnostic carries the whole rule with it. Every E0307 in this guide's probed set is followed by the same note - "type of self must be Self or a type that dereferences to it" - and the same help line listing the valid forms: self, &self, &mut self, self: Box<Self>, self: Rc<Self>, self: Arc<Self>, or self: Pin<P>. The second payoff is knowing how far the rule reaches: it is the target type that matters, not the wrapper, so Box<Bar> fails for the same reason &Bar does, while &Foo - the concrete name of the implementing type - passes just as &Self does. Neighboring codes in this area are E0308, mismatched types, and E0309, a type that may not live long enough; E0307 is specifically the receiver shape.

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 receiver must lead back to the implementing type

A method's first parameter is not an ordinary parameter. It decides what value the method is called on, how that value is borrowed or owned, and which values can call the method at all. For that to work, its type has to be the implementing type itself, a reference to it, or one of the standard wrappers that dereference to it.

The index puts the three common forms first: "Methods take a special first parameter, of which there are three variants: self, &self, and &mut self. These are syntactic sugar for self: Self, self: &Self, and self: &mut Self respectively." It then extends the list: "Besides the already mentioned Self, &Self and &mut Self valid receiver types, the following are also valid: self: Box<Self>, self: Rc<Self>, self: Arc<Self>, and self: Pin<P> (where P is one of the previous types except Self)." In the probed set, everything else tried - an unrelated struct, a primitive, a standard type that is not about the receiver, or a valid wrapper around the wrong target - was refused with E0307 at the declaration, before any call site was considered.

How to read the diagnostic

In the probed set, a clean E0307 failure is a single error followed by a note and a help line. The header names the written type: "invalid self parameter type: &Bar". The carets sit under the receiver type alone. The note then states the rule - "type of self must be Self or a type that dereferences to it" - and the help line lists the valid receiver forms to change to.

Two warnings about reading it. First, the header names the type as written, normalized: a receiver written as Vec<Self> is reported as Vec<Foo>, with Self already resolved to the implementing type. Second, E0307 can arrive with company: the index's own trait example, where the trait declares &self and the implementation writes self: &Bar, drew E0053 (method has an incompatible type for trait) first and E0307 second on the probed toolchain. When two codes appear, fix the receiver type - both errors are about the same parameter.

The first failure: a reference to the wrong type

The smallest shape is the index's mistake moved into an inherent implementation, where it draws E0307 alone - a method on Foo whose receiver claims to be a reference to Bar:

Rust
struct Foo;
struct Bar;
impl Foo { fn foo(self: &Bar) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `&Bar`
 --> clean_ref_bar.rs:3:25
  |
3 | impl Foo { fn foo(self: &Bar) {} }
  |                         ^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 1 previous error

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

Nothing is wrong with Bar, with references, or with the method body. The one defect is the mismatch between the type after impl and the type after self: - the receiver names a type the method is not implemented on.

The same error across the wrong shapes

A primitive fails the same way. An i32 is a perfectly good ordinary parameter, but as a receiver it names a type that is not Foo:

Rust
struct Foo;
impl Foo { fn foo(self: i32) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `i32`
 --> clean_i32.rs:2:25
  |
2 | impl Foo { fn foo(self: i32) {} }
  |                         ^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 1 previous error

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

A standard library type by value fails too:

Rust
struct Foo;
impl Foo { fn foo(self: String) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `String`
 --> clean_string.rs:2:25
  |
2 | impl Foo { fn foo(self: String) {} }
  |                         ^^^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 1 previous error

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

Borrowing the wrong type does not soften it. A &String receiver fails with the same note and help:

Rust
struct Foo;
impl Foo { fn foo(self: &String) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `&String`
 --> clean_ref_string.rs:2:25
  |
2 | impl Foo { fn foo(self: &String) {} }
  |                         ^^^^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 1 previous error

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

And a valid wrapper around the wrong target fails as well. Box is on the help line's list, but Box<Bar> points at the wrong type:

Rust
struct Foo;
struct Bar;
impl Foo { fn foo(self: Box<Bar>) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `Box<Bar>`
 --> clean_box_bar.rs:3:25
  |
3 | impl Foo { fn foo(self: Box<Bar>) {} }
  |                         ^^^^^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 1 previous error

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

Even a wrapper that contains Self fails when the wrapper itself is not a receiver form. A Vec<Self> holds the right type and is still refused, with the header resolving Self to Foo:

Rust
struct Foo;
impl Foo { fn foo(self: Vec<Self>) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `Vec<Foo>`
 --> clean_vec.rs:2:25
  |
2 | impl Foo { fn foo(self: Vec<Self>) {} }
  |                         ^^^^^^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 1 previous error

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

In the probed set, the failing family also included Bar by value, &mut Bar, &Vec<Self>, and Pin<&mut Bar> - the Pin form from the help line, wrapped around the wrong target. Six shapes are shown in full above; every one drew the identical note and help, and the only variation is the type named in the header and underlined.

The repair: name Self, or the implementing type itself

The direct repair of the first failure is to write the receiver the help line offers. self: &Self compiles and the method runs:

Rust
struct Foo;
impl Foo { fn foo(self: &Self) { println!("refSelf"); } }
fn main() { Foo.foo(); }
Output
refSelf

The index adds a second spelling of the same repair: "Self can also be the underlying implementing type." Writing the concrete name, &Foo, in a trait implementation compiled and ran identically in the probed set:

Rust
struct Foo;
trait Trait { fn foo(&self); }
impl Trait for Foo { fn foo(self: &Foo) { println!("concrete"); } }
fn main() { Foo.foo(); }
Output
concrete

The output is concrete. The same held by value and under a wrapper in the probed set: self: Foo and self: Box<Foo> both compiled and ran. So the choice between Self and the concrete name is a style choice; the compiler accepts either, in any of the valid wrapper forms.

The boundary: every listed receiver form runs

The three sugar forms all compiled and ran in the probed set. By value:

Rust
struct Foo;
impl Foo { fn foo(self) { println!("plain"); } }
fn main() { Foo.foo(); }
Output
plain

By shared reference:

Rust
struct Foo;
impl Foo { fn foo(&self) { println!("ref"); } }
fn main() { Foo.foo(); }
Output
ref

By mutable reference:

Rust
struct Foo;
impl Foo { fn foo(&mut self) { println!("refmut"); } }
fn main() { let mut f = Foo; f.foo(); }
Output
refmut

Their explicit spellings ran too: self: Self printed its marker, as did self: &mut Self. One explicit spelling carries a small surprise: an explicit lifetime on the reference, self: &'a Self, also compiled and ran in the probed set - the lifetime is accepted as part of the reference form, not treated as a different receiver type.

The wrapper forms from the help line each compiled and ran. Under Box:

Rust
struct Foo;
impl Foo { fn foo(self: Box<Self>) { println!("box"); } }
fn main() { Box::new(Foo).foo(); }
Output
box

Under Rc:

Rust
use std::rc::Rc;
struct Foo;
impl Foo { fn foo(self: Rc<Self>) { println!("rc"); } }
fn main() { Rc::new(Foo).foo(); }
Output
rc

In the probed set, Arc<Self> ran the same way, printing its marker, and so did both Pin forms: Pin<&mut Self> called through a pinned mutable reference, and Pin<&Self> through a pinned shared one. The legal set verified running in the probed set is: self, &self, &mut self, self: Self, self: &Self, self: &mut Self, self: Box<Self>, self: Rc<Self>, self: Arc<Self>, self: Pin<&mut Self>, and self: Pin<&Self> - plus the same forms spelled with the concrete type name in place of Self.

The boundary: a wrong receiver in a trait is wrong twice

When the invalid receiver is written in a trait declaration itself, the compiler reports it at both the declaration and the implementation. This program writes self: &Bar in both places:

Rust
struct Foo;
struct Bar;
trait Trait { fn foo(self: &Bar); }
impl Trait for Foo { fn foo(self: &Bar) {} }
fn main() {}
Output
error[E0307]: invalid `self` parameter type: `&Bar`
 --> trait_wrong.rs:4:35
  |
4 | impl Trait for Foo { fn foo(self: &Bar) {} }
  |                                   ^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error[E0307]: invalid `self` parameter type: `&Bar`
 --> trait_wrong.rs:3:28
  |
3 | trait Trait { fn foo(self: &Bar); }
  |                            ^^^^
  |
  = note: type of `self` must be `Self` or a type that dereferences to it
  = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)

error: aborting due to 2 previous errors

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

Two E0307 errors here are one mistake written twice, not two mistakes. Fix the declaration and the implementation together - changing only one leaves the other still naming &Bar.

The boundary: what is not E0307

A method with no self parameter at all is not an invalid method - it is an associated function, called on the type rather than on a value:

Rust
struct Foo;
impl Foo { fn foo() { println!("assoc"); } }
fn main() { Foo::foo(); }
Output
assoc

And the receiver rule binds only the first parameter. A second, ordinary parameter of any type - here the i32 that failed as a receiver - is fine after a valid receiver:

Rust
struct Foo;
impl Foo { fn foo(&self, x: i32) { println!("second {}", x); } }
fn main() { Foo.foo(42); }
Output
second 42

The output is second 42. If a type like i32 or String belongs in your method, it almost always belongs in that second position, with a real receiver in the first.

A missing receiver is a call-site problem, not a declaration problem, and it draws a different code. Calling a method through the type without supplying the receiver is E0061:

Rust
struct Foo;
impl Foo { fn foo(&self) { println!("hi"); } }
fn main() { Foo::foo(); }
Output
error[E0061]: this function takes 1 argument but 0 arguments were supplied
 --> missing_self_call.rs:3:13
  |
3 | fn main() { Foo::foo(); }
  |             ^^^^^^^^-- argument #1 of type `&Foo` is missing
  |
note: method defined here
 --> missing_self_call.rs:2:15
  |
2 | impl Foo { fn foo(&self) { println!("hi"); } }
  |               ^^^ -----
help: provide the argument
  |
3 | fn main() { Foo::foo(/* &Foo */); }
  |                      ++++++++++

error: aborting due to 1 previous error

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

So the situations separate cleanly: a receiver type that does not lead back to the implementing type is E0307 at the declaration, a valid declaration called without its receiver is E0061 at the call, and a declaration with no receiver is an associated function with no error at all. The code in the header tells you which of the three you are in before you change anything.

Fixes in reach order

First, replace the receiver type with one from the diagnostic's own help line. Pick by how the method uses the value: &self for a read, &mut self for a mutation, self for a consuming method, and Box<Self>, Rc<Self>, Arc<Self>, or a Pin form when callers hold the value in that wrapper. In the probed set, that single change took every failing declaration to compiling.

Second, if the written type was a wrapper, check its target before changing the wrapper. Box<Bar>, Pin<&mut Bar>, and &Bar all failed for the target, not the shape: the repair is Box<Self> or &Self, keeping the wrapper you meant and fixing what it points at.

Third, if the type you wrote is data the method needs rather than the value it is called on, move it to the second parameter. An i32 or a String after a valid receiver is an ordinary parameter and compiles as one; as the first parameter it can only ever be read as a receiver claim.

Last, when the error appears in a trait, fix the declaration and every implementation in the same pass. The compiler reports each written copy, and a trait-impl pair that disagrees about the receiver can add E0053 on top of E0307 - both clear when the receiver names the implementing type in both places.

Decision summary

E0307, in this guide's probed set, fired exactly when a method's self parameter named a type that is not the implementing type, a reference to it, or a listed wrapper around it: &Bar, Bar, &mut Bar, Box<Bar>, Pin<&mut Bar>, i32, String, &String, Vec<Self>, and &Vec<Self>. Every diagnostic was a single error naming the written type (with Self resolved to the implementing type in the header), carets under the receiver type, a note stating that the type of self must be Self or a type that dereferences to it, and a help line listing the valid forms. Compiling and running were self, &self, &mut self, self: Self, self: &Self, self: &mut Self, self: Box<Self>, self: Rc<Self>, self: Arc<Self>, self: Pin<&mut Self>, and self: Pin<&Self>, plus the concrete-name spellings self: Foo, self: &Foo, and self: Box<Foo>, and an explicit-lifetime self: &'a Self. A receiver written wrong in both a trait and its implementation drew E0307 twice; the index's trait-mismatch shape drew E0053 alongside E0307. No receiver at all made an associated function, a second ordinary parameter of a refused type compiled, and a call missing its receiver drew E0061.

Checklist

  • Read the note first: the receiver must be Self or a type that dereferences to it - that one sentence decides every case.
  • Pick the receiver from the help line's list: self, &self, &mut self, Box<Self>, Rc<Self>, Arc<Self>, or a Pin form.
  • Check the wrapper's target, not just the wrapper: Box<Bar> fails exactly as &Bar does.
  • Do not reach for containers: Vec<Self> contains the right type and is still not a receiver.
  • Move data parameters to the second position: refused receiver types are ordinary parameters there.
  • Fix traits and implementations together: each written copy of a wrong receiver is reported separately.

Sources

  • Rust error codes index, E0307 - the self parameter in a method has an invalid receiver type; the erroneous example implementing a trait for Foo with fn foo(self: &Bar), the statement that self, &self, and &mut self are syntactic sugar for self: Self, self: &Self, and self: &mut Self, the list of further valid receiver types (Box<Self>, Rc<Self>, Arc<Self>, and Pin<P>), and the note that Self can also be the underlying implementing type.

Keep Exploring