E0185 Method Has Self but Trait Does Not Fix
Written December 3, 2026 · Tested with Rust 1.99.0 · 15 min read
- 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 E0185 means a trait's associated function was declared to be static - it takes no self parameter - but an implementation of the trait declared the same function as a method, taking a self parameter. The error codes index example declares fn foo(); in the trait Foo and then implements it as fn foo(&self) 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 E0185 and no other code - this premise is clean, with no ride-along to separate. The receiver's exact form makes no difference, in the probed shapes: an implementation taking &self, one taking self by value, one taking &mut self, and one taking self: Box<Self> each drew exactly one E0185 when the trait declared no self at all, and so did an implementation that added &self ahead of an otherwise identical argument list. The count follows the mismatched methods, in the probed shape: two methods of one trait each implemented with a self the trait did not declare drew exactly two E0185 reports, one per method. The reverse mismatch is a different code, in the probed shape: a trait method declared with &self and implemented with no self parameter drew exactly one E0186, not E0185 - 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 E0185 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 E0185 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 without self is an associated function, called through the type, as Bar::foo(); a function declared with self is a method, called on a value, as b.foo(). The index entry states the consequence directly: an implementation has to use the same signature as the trait, so an implementation that adds a self the trait never 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 drops the self parameter and the function stays static - the index's own corrected example takes this route - or the trait declaration gains the self parameter and the function becomes a method on both sides, with call sites changing to match.
How to read the diagnostic
The E0185 header names the mismatch and its direction: "method foo has a &self declaration in the impl, but not in the trait". The report carries two spans: the trait declaration, labeled "trait method declared without &self", and the implementation, labeled "&self used 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 trait but not in the implementation, is E0186, and it is repaired on the opposite side.
The count follows the mismatched methods, in the probed shape - one report per method whose implementation adds a self. Two such methods in one implementation drew two reports, ending with "aborting due to 2 previous errors":
error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait
--> fail_two_methods.rs:9:5
|
2 | fn foo();
| --------- trait method declared without `&self`
...
9 | fn foo(&self) {}
| ^^^^^^^^^^^^^ `&self` used in impl
error[E0185]: method `bar` has a `&self` declaration in the impl, but not in the trait
--> fail_two_methods.rs:10:5
|
3 | fn bar();
| --------- trait method declared without `&self`
...
10 | fn bar(&self) {}
| ^^^^^^^^^^^^^ `&self` used in impl
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0185`.
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 no self parameter, and the implementation adds &self:
#![allow(unused)]
fn main() {
trait Foo {
fn foo();
}
struct Bar;
impl Foo for Bar {
// error, method `foo` has a `&self` declaration in the impl, but not in
// the trait
fn foo(&self) {}
}
}
error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait
--> fail_index.rs:12:5
|
4 | fn foo();
| --------- trait method declared without `&self`
...
12 | fn foo(&self) {}
| ^^^^^^^^^^^^^ `&self` used in impl
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0185`.
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 static function is not the problem: the same trait implemented with the same static signature compiled and ran in the probed shape, shown in the boundary section below. And a method is not the problem either: a trait declaring &self, implemented with &self, compiled and ran in the same section.
The same error in the other shapes
The ban follows the added self, not its exact form. An implementation taking self by value drew exactly one E0185 in the probed shape, in the file fail_owned_self.rs; one taking &mut self drew exactly one in the file fail_mut_self.rs; and one taking an explicit self: Box<Self> receiver drew exactly one in the file fail_box_self.rs. Adding self ahead of real arguments changes nothing either: a trait function declared as fn foo(x: i32) -> i32 and implemented as fn foo(&self, x: i32) -> i32 drew exactly one E0185 in the probed shape, in the file fail_self_with_args.rs - the argument list agreed, and the added receiver alone was the defect. Every receiver form an implementation can write draws this one code when the trait declared none.
One co-report belongs here. A program that carried the index mismatch and an unresolved name in main reported both - exactly one E0185 and one E0425, in the file ride_unresolved.rs:
error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait
--> ride_unresolved.rs:8:5
|
2 | fn foo();
| --------- trait method declared without `&self`
...
8 | fn foo(&self) {}
| ^^^^^^^^^^^^^ `&self` used 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: E0185, E0425.
For more information about an error, try `rustc --explain E0185`.
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 method declared with &self, implemented with no self parameter at all, drew exactly one E0186 and no E0185 in the probed shape:
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
--> fail_reverse.rs:8:5
|
2 | fn foo(&self);
| -------------- `&self` used in trait
...
8 | fn foo() {}
| ^^^^^^^^ expected `&self` in impl
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0186`.
The E0186 report is the mirror image - self declared in the trait, missing in the implementation - and its repair runs the other way: the implementation gains the self, or the trait loses it. Read the header's direction to tell the two apart before choosing a side to edit: E0185 says the self is in the impl but not in the trait; E0186 says the opposite.
The other signature disagreements land in their own codes. An implementation declaring fewer arguments than the trait - none, where the trait declared one - drew exactly one E0050 in the probed shape:
error[E0050]: method `foo` has 0 parameters but the declaration in trait `Foo::foo` has 1
--> neighbor_arg_count.rs:8:5
|
2 | fn foo(x: i32);
| --- trait requires 1 parameter
...
8 | fn foo() {}
| ^^^^^^^^ expected 1 parameter, found 0
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:
error[E0053]: method `foo` has an incompatible type for trait
--> neighbor_return_type.rs:8:13
|
8 | fn foo() {}
| ^ expected `i32`, found `()`
|
note: type in trait
--> neighbor_return_type.rs:2:17
|
2 | fn foo() -> i32;
| ^^^
= note: expected signature `fn() -> i32`
found signature `fn() -> ()`
help: change the output type to match the trait
|
8 | fn foo() -> 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:
error[E0046]: not all trait items implemented, missing: `bar`
--> neighbor_missing_method.rs:8:1
|
3 | fn bar();
| --------- `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 E0185: 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 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 first repair below. And 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. Static functions and methods both work; a signature that changes between the trait and its implementation does not.
Related guides
For the reverse mismatch - self declared in the trait and missing in the implementation - the neighboring code is E0186. 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 - through the type, or on a value.
Remove self from the implementation. This is the repair when the function never needed a value - the index's own corrected example takes it, and the function stays an associated function, called through the type:
trait Foo {
fn foo();
}
struct Bar;
impl Foo for Bar {
fn foo() {
println!("static foo");
}
}
fn main() {
Bar::foo();
}
static foo
The call is Bar::foo() - no value is created to call it on, and the function prints its line exactly as a static function should, in the probed shape.
Add self to the trait declaration instead. This is the repair when the function genuinely works on a value - the trait gains &self, the implementation keeps it, and callers switch from the type path to a value:
trait Foo {
fn foo(&self);
}
struct Bar;
impl Foo for Bar {
fn foo(&self) {
println!("method foo");
}
}
fn main() {
let b = Bar;
b.foo();
}
method foo
The call is now b.foo() on a value of the type. Every other implementation of the same trait must gain 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 method shape is the intended design.
Callers change with the repair choice in one visible way: the remove-self repair keeps call sites on the type path, while the add-self repair moves every call site onto a value - 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 impl, but not in the trait" is E0185, the implementation-side self. A report that the self is declared in the trait but not in the impl is E0186, 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 never uses a value of the type, it is an associated function: remove the self parameter from the implementation - that clears every E0185 on that method at once.
Third, if the function does work on a value, add the self parameter to the trait declaration instead, and update the other implementations of the trait and the call sites to the method 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 E0185, and both must be fixed before the program compiles.
Decision summary
E0185 fired in the probed shapes for the index example verbatim (exactly one E0185, no other code), for two mismatched methods in one implementation (exactly two, one per method), for implementations taking self by value, &mut self, and self: Box<Self> (exactly one each), and for an implementation adding &self 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 E0185, neither masking the other. It did not fire, in the probed shapes, for a static function implemented as declared (compiled and ran, printing static foo) or for a method declared and implemented with &self (compiled and ran, printing 42). The neighboring shapes drew other reports instead in the probed shapes: the reverse mismatch drew exactly one E0186, 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 removing self from the implementation (printing static foo) and adding self to the trait declaration (printing method foo).
Checklist
- The test is the direction of the mismatch, in the probed shapes: E0185 is a self in the implementation that the trait never declared - the reverse direction is E0186.
- The receiver's form does not matter, in the probed shapes:
&self,self,&mut self, andself: Box<Self>in the implementation each drew the same single E0185. - 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: static-on-static and method-on-method both compiled and ran.
- An unresolved name does not mask this error, in the probed shape: E0185 and E0425 were reported together, as two defects.
- One side changes in every repair, in the probed shapes: the implementation loses its self, or the trait gains one - and the call sites follow the side that changed.
Sources
- 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 erroneous example declares
fn foo()in a trait and implements it with&self, and the entry states that an implementation has to use the same signature as the trait, showing the corrected implementation without self. - 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 reverse mismatch drawn in the probed shape by a trait method with
&selfimplemented without 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
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.