E0186 Method Lacks Self but Trait Has It Fix

Written December 3, 2026 · Tested with Rust 1.99.0 · 15 min read

By the end of this guide
  • The rule underneath: an implementation repeats the trait's signature
  • How to read the diagnostic
  • The first failure: the index example
  • The same error in the other shapes

Written December 3, 2026

Tested with Rust 1.99.0

What this guide is

Error E0186 means a trait's associated function was declared to be a method - it takes a self parameter - but an implementation of the trait declared the same function as static, taking no self parameter. The error codes index example declares fn foo(&self); in the trait Foo and then implements it as fn foo() for the struct Bar, and the index states the rule the example breaks: when a type implements a trait's associated function, it has to use the same signature.

In the shapes probed in this guide, the index example verbatim drew exactly one E0186 and no other code - this premise is clean, with no ride-along to separate. The receiver's exact form in the trait makes no difference, in the probed shapes: a trait declaring &self, one declaring self by value, one declaring &mut self, and one declaring self: Box<Self> each drew exactly one E0186 when the implementation carried no self at all, and so did an implementation that dropped &self from ahead of an otherwise identical argument list. The count follows the mismatched methods, in the probed shape: two methods of one trait each implemented without the self the trait declared drew exactly two E0186 reports, one per method. The reverse mismatch is a different code, in the probed shape: a trait function declared with no self and implemented with &self drew exactly one E0185, not E0186 - the two codes split on which side carries the self. The neighboring signature defects land elsewhere again, in the probed shapes: an implementation with the wrong number of arguments drew exactly one E0050, one with the wrong return type drew exactly one E0053, and an implementation missing a required method entirely drew exactly one E0046. An unresolved name elsewhere in the program did not hide this error in the probed shape: it was reported alongside, one E0186 and one E0425. Neither side's shape is banned on its own: a static function declared and implemented without self compiled and ran, and a method declared and implemented with &self compiled and ran, in the probed shapes. This guide shows the E0186 shapes, the neighboring shapes, the boundary, 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: an implementation repeats the trait's signature

A trait declaration fixes each associated function's signature, and the self parameter is part of that signature - it is what decides how the function is called. A function declared with self is a method, called on a value, as b.foo(); a function declared without self is an associated function, called through the type, as Bar::foo(). The index entry states the consequence directly: an implementation has to use the same signature as the trait, so an implementation that drops a self the trait declared is not an implementation of that function at all, and the compiler reports the mismatch instead of accepting a second, different function under the same name.

That is why every repair makes the two sides agree. Either the implementation gains the self parameter and the function stays a method - the index's own corrected example takes this route - or the trait declaration loses the self parameter and the function becomes static on both sides, with call sites changing to match.

How to read the diagnostic

The E0186 header names the mismatch and its direction: "method foo has a &self declaration in the trait, but not in the impl". The report carries two spans: the trait declaration, labeled "&self used in trait", and the implementation, labeled "expected &self in impl". There is no suggested fix in the report; choosing which side to change is the repair decision below. Read the direction before editing anything - the reverse direction, self in the implementation but not in the trait, is E0185, and it is repaired on the opposite side.

The count follows the mismatched methods, in the probed shape - one report per method whose implementation drops a declared self. Two such methods in one implementation drew two reports, ending with "aborting due to 2 previous errors":

Output
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
 --> fail_two_methods.rs:9:5
  |
2 |     fn foo(&self);
  |     -------------- `&self` used in trait
...
9 |     fn foo() {}
  |     ^^^^^^^^ expected `&self` in impl

error[E0186]: method `bar` has a `&self` declaration in the trait, but not in the impl
  --> fail_two_methods.rs:10:5
   |
 3 |     fn bar(&self);
   |     -------------- `&self` used in trait
...
10 |     fn bar() {}
   |     ^^^^^^^^ expected `&self` in impl

error: aborting due to 2 previous errors

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

Fix every mismatched method in the output before recompiling; a second one is already reported, not hidden behind the first.

The first failure: the index example

The index's erroneous example, verbatim - the trait declares foo with &self, and the implementation drops it:

Rust
#![allow(unused)]
fn main() {
trait Foo {
    fn foo(&self);
}

struct Bar;

impl Foo for Bar {
    // error, method `foo` has a `&self` declaration in the trait, but not in
    // the impl
    fn foo() {}
}
}
Output
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
  --> fail_index.rs:12:5
   |
 4 |     fn foo(&self);
   |     -------------- `&self` used in trait
...
12 |     fn foo() {}
   |     ^^^^^^^^ expected `&self` in impl

error: aborting due to 1 previous error

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

Exactly one report, and it is the whole story: no second code rides along in this example. The separation checks confirm the signature is the only defect. A method is not the problem: the same trait implemented with the same method signature compiled and ran in the probed shape, shown in the boundary section below. And a static function is not the problem either: a trait declaring no self, implemented with no self, compiled and ran in the same section.

The same error in the other shapes

The ban follows the dropped self, not its exact form in the trait. A trait declaring self by value drew exactly one E0186 in the probed shape, in the file fail_owned_self.rs - its header names a self declaration rather than a &self one, and the code is the same. A trait declaring &mut self drew exactly one in the file fail_mut_self.rs; and one declaring an explicit self: Box<Self> receiver drew exactly one in the file fail_box_self.rs. Dropping self from ahead of real arguments changes nothing either: a trait method declared as fn foo(&self, x: i32) -> i32 and implemented as fn foo(x: i32) -> i32 drew exactly one E0186 in the probed shape, in the file fail_self_with_args.rs - the argument list agreed, and the dropped receiver alone was the defect. Every receiver form a trait can declare draws this one code when the implementation omits it.

One co-report belongs here. A program that carried the index mismatch and an unresolved name in main reported both - exactly one E0186 and one E0425, in the file ride_unresolved.rs:

Output
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
 --> ride_unresolved.rs:8:5
  |
2 |     fn foo(&self);
  |     -------------- `&self` used in trait
...
8 |     fn foo() {}
  |     ^^^^^^^^ expected `&self` in impl

error[E0425]: cannot find function `missing_name` in this scope
  --> ride_unresolved.rs:12:5
   |
12 |     missing_name();
   |     ^^^^^^^^^^^^ not found in this scope

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0186, E0425.
For more information about an error, try `rustc --explain E0186`.

Read the pair as two separate defects, not one defect stated twice: the name error does not mask the signature error in this shape, and fixing either one leaves the other standing.

The shapes that are not this error

Reversing the mismatch changes the code. A trait function declared with no self parameter, implemented with &self, drew exactly one E0185 and no E0186 in the probed shape:

Output
error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait
 --> fail_reverse.rs:8:5
  |
2 |     fn foo();
  |     --------- trait method declared without `&self`
...
8 |     fn foo(&self) {}
  |     ^^^^^^^^^^^^^ `&self` used in impl

error: aborting due to 1 previous error

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

The E0185 report is the mirror image - self present in the implementation, never declared in the trait - and its repair runs the other way: the implementation loses the self, or the trait gains it. Read the header's direction to tell the two apart before choosing a side to edit: E0186 says the self is in the trait but not in the impl; E0185 says the opposite.

The other signature disagreements land in their own codes. An implementation declaring fewer arguments than the trait - only &self, where the trait declared &self and one more argument - drew exactly one E0050 in the probed shape:

Output
error[E0050]: method `foo` has 1 parameter but the declaration in trait `Foo::foo` has 2
 --> neighbor_arg_count.rs:8:12
  |
2 |     fn foo(&self, x: i32);
  |            ------------- trait requires 2 parameters
...
8 |     fn foo(&self) {}
  |            ^^^^^ expected 2 parameters, found 1

error: aborting due to 1 previous error

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

An implementation whose return type disagrees with the trait - no return value, where the trait declared i32 - drew exactly one E0053 in the probed shape:

Output
error[E0053]: method `foo` has an incompatible type for trait
 --> neighbor_return_type.rs:8:18
  |
8 |     fn foo(&self) {}
  |                  ^ expected `i32`, found `()`
  |
note: type in trait
 --> neighbor_return_type.rs:2:22
  |
2 |     fn foo(&self) -> i32;
  |                      ^^^
  = note: expected signature `fn(&Bar) -> i32`
             found signature `fn(&Bar) -> ()`
help: change the output type to match the trait
  |
8 |     fn foo(&self) -> i32 {}
  |                   ++++++

error: aborting due to 1 previous error

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

And an implementation that omits a required method entirely drew exactly one E0046 in the probed shape:

Output
error[E0046]: not all trait items implemented, missing: `bar`
 --> neighbor_missing_method.rs:8:1
  |
3 |     fn bar(&self);
  |     -------------- `bar` from trait
...
8 | impl Foo for Bar {
  | ^^^^^^^^^^^^^^^^ missing `bar` in implementation

error: aborting due to 1 previous error

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

None of these shapes drew E0186: each fails at a different part of the signature contract - the argument count, the return type, and the method's presence are checked separately from the self parameter.

The boundary: the same signature on both sides

The line is the agreement. On the other side of it, both call shapes are ordinary code. A trait method declared with &self and implemented with &self compiled and ran in the probed shape, printing 42, in the file boundary_both_self.rs - the value the method returned. And a trait function declared without self and implemented without self compiled and ran in the probed shape, called through the type as Bar::foo(), printing static foo - that program is also the second repair below. Methods and static functions both work; a signature that changes between the trait and its implementation does not.

For the reverse mismatch - self present in the implementation and never declared in the trait - the neighboring code is E0185. For an implementation with the wrong number of arguments, the code is E0050. For a method whose return type disagrees with the trait, the code is E0053. For an implementation missing a required item, the code is E0046. For an unresolved name reported alongside a signature error, the code is E0425.

The repairs

Every repair below starts from the same observation: the trait and the implementation must carry the same signature, so one side changes to match the other. What changes for callers is how the function is called afterward - on a value, or through the type.

Add self to the implementation. This is the repair when the function genuinely works on a value - the index's own corrected example takes it, and the function stays a method, called on a value:

Rust
trait Foo {
    fn foo(&self);
}

struct Bar;

impl Foo for Bar {
    fn foo(&self) {
        println!("method foo");
    }
}

fn main() {
    let b = Bar;
    b.foo();
}
Output
method foo

The call is b.foo() on a value of the type - a value is created to call it on, and the function prints its line exactly as a method should, in the probed shape.

Remove self from the trait declaration instead. This is the repair when the function never needed a value - the trait loses &self, the implementation keeps its static shape, and callers switch from a value to the type path:

Rust
trait Foo {
    fn foo();
}

struct Bar;

impl Foo for Bar {
    fn foo() {
        println!("static foo");
    }
}

fn main() {
    Bar::foo();
}
C
static foo

The call is now Bar::foo() - no value is created to call it on. Every other implementation of the same trait must lose the self as well - changing the trait changes the contract for all of them at once, which is why this repair is the right one only when the static shape is the intended design.

Callers change with the repair choice in one visible way: the add-self repair keeps call sites on a value, while the remove-self repair moves every call site onto the type path - and any other type implementing the same trait has to match the new declaration before the program compiles again.

Fixes in reach order

First, read the header and its direction. "Method foo has a &self declaration in the trait, but not in the impl" is E0186, the trait-side self. A report that the self is in the impl but not in the trait is E0185, a report about the number of arguments is E0050, a report about the method's type is E0053, and a report that an implementation is missing a method is E0046 - each is repaired where it is written.

Second, decide which shape the function is meant to be. If it does work on a value, it is a method: add the self parameter to the implementation - that clears every E0186 on that method at once.

Third, if the function never uses a value of the type, remove the self parameter from the trait declaration instead, and update the other implementations of the trait and the call sites to the static shape.

Fourth, recompile and read what remains on its own terms: if the output carries a second code, separate it before judging the program - an E0425 for an unresolved name is a second, independent defect reported alongside the E0186, and both must be fixed before the program compiles.

Decision summary

E0186 fired in the probed shapes for the index example verbatim (exactly one E0186, no other code), for two mismatched methods in one implementation (exactly two, one per method), for traits declaring self by value, &mut self, and self: Box<Self> (exactly one each), and for an implementation dropping &self from ahead of an agreeing argument list (exactly one). It was reported alongside another code in one probed shape: an unresolved name in the same program drew one E0425 next to the one E0186, neither masking the other. It did not fire, in the probed shapes, for a method declared and implemented with &self (compiled and ran, printing 42) or for a static function implemented as declared (compiled and ran, printing static foo). The neighboring shapes drew other reports instead in the probed shapes: the reverse mismatch drew exactly one E0185, a wrong argument count drew exactly one E0050, a wrong return type drew exactly one E0053, and a missing required method drew exactly one E0046. The repairs that compiled and ran in the probed shapes were adding self to the implementation (printing method foo) and removing self from the trait declaration (printing static foo).

Checklist

  • The test is the direction of the mismatch, in the probed shapes: E0186 is a self in the trait that the implementation never carried - the reverse direction is E0185.
  • The receiver's form in the trait does not matter, in the probed shapes: &self, self, &mut self, and self: Box<Self> declared in the trait each drew the same single E0186.
  • The count is per mismatched method, in the probed shape: two such methods in one implementation drew two reports.
  • Neither shape is the problem alone, in the probed shapes: method-on-method and static-on-static both compiled and ran.
  • An unresolved name does not mask this error, in the probed shape: E0186 and E0425 were reported together, as two defects.
  • One side changes in every repair, in the probed shapes: the implementation gains its self, or the trait loses one - and the call sites follow the side that changed.

Sources

  • Rust error codes index, E0186 - an associated function for a trait was defined to be a method, but an implementation of the trait declared the same function to be static; the erroneous example declares fn foo(&self) in a trait and implements it with no self parameter, and the entry states that an implementation has to use the same signature as the trait, showing the corrected implementation with &self.
  • Rust error codes index, E0185 - an associated function for a trait was defined to be static, but an implementation of the trait declared the same function to be a method; the reverse mismatch drawn in the probed shape by a trait function with no self implemented with &self.
  • Rust error codes index, E0050 - a method implementation had an incorrect number of parameters; the neighboring code drawn in the probed shape by an implementation declaring fewer arguments than its trait.
  • Rust error codes index, E0053 - the parameters of any trait method must match between a trait implementation and the trait definition; the neighboring code drawn in the probed shape by an implementation whose return type disagreed with its trait.
  • Rust error codes index, E0046 - an item was missing in an implementation; the neighboring code drawn in the probed shape by an implementation omitting a required method.

Keep Exploring