Rust

E0407 Method Not in Trait Fix

A trait implementation is a closed list: it may define the items the trait declares, and nothing else. One extra method inside the impl block — a helper that seemed to belong with the trait methods — stops the whole program, even when every required method is present and correct. Move the extra method to an inherent impl on the type, declare it on the trait itself, or give it a trait of its own, and the same code compiles with the method still callable exactly as before.

Written November 26, 2026 · Tested with Rust 1.99.1 · 19 min read

By the end of this guide
  • The error: an extra method in an impl of your own trait
  • The same surplus in a generic trait impl
  • An extra method in a standard trait impl
  • The typo case: E0407 reported together with E0046

Written November 26, 2026

Tested with Rust 1.99.1

What this guide is

This error is one method in the wrong block. A trait implementation may define the items the trait declares — all of its required items, and any of its default items the impl chooses to override — and no others. A method written inside impl Trait for Type that appears nowhere in the trait's declaration is not an extension of the trait and not a private helper for the impl: it is an item the impl is not allowed to contain, and the compiler rejects the whole program for it, however correct the rest of the block is.

That is why the repairs below never touch the trait methods themselves. The extra method is good code in the wrong place, and each repair moves it to a place where extra methods are allowed: an inherent impl block on the type itself, the trait declaration (when the trait is yours and every implementor should have the method), or a second trait of your own implemented alongside the first. The shapes differ only in which trait is involved — a trait you defined, a generic trait, a standard library trait you cannot edit — and in one case the extra method is not extra at all but a required method under a misspelled name, which the compiler reports with a second error alongside this one.

The error: an extra method in an impl of your own trait

Greet declares one method, greet. The impl below supplies it correctly — and then adds farewell, which the trait never mentions:

Rust
trait Greet {
    fn greet(&self) -> String;
}

struct Person {
    name: String,
}

impl Greet for Person {
    fn greet(&self) -> String {
        format!("Hello, {}", self.name)
    }

    fn farewell(&self) -> String {
        format!("Bye, {}", self.name)
    }
}

fn main() {
    let p = Person {
        name: String::from("Ada"),
    };
    println!("{}", p.greet());
}
Terminal
$ rustc --edition 2021 broken.rs -o broken.bin
error[E0407]: method `farewell` is not a member of trait `Greet`
  --> broken.rs:14:5
   |
14 | /     fn farewell(&self) -> String {
15 | |         format!("Bye, {}", self.name)
16 | |     }
   | |_____^ not a member of trait `Greet`

error: aborting due to 1 previous error

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

Read the span, because it is the whole diagnosis. The caret block covers the entire farewell method and labels it not a member of trait Greet: the method itself is well-formed, its signature is legal, and its body would compile anywhere else. The defect is purely its location. Note also what the error does not say — nothing is missing. Every item Greet requires is present, which is the opposite of E0046, the missing-items error; this impl has a surplus, not an omission.

The standard repair is to move the extra method into an inherent impl block — a plain impl Person with no trait named — where a type's own additional methods belong:

Rust
trait Greet {
    fn greet(&self) -> String;
}

struct Person {
    name: String,
}

impl Greet for Person {
    fn greet(&self) -> String {
        format!("Hello, {}", self.name)
    }
}

impl Person {
    fn farewell(&self) -> String {
        format!("Bye, {}", self.name)
    }
}

fn main() {
    let p = Person {
        name: String::from("Ada"),
    };
    println!("{}", p.greet());
    println!("{}", p.farewell());
}
Terminal
$ rustc --edition 2021 fixed_inherent.rs -o fixed_inherent.bin
$ ./fixed_inherent.bin
Hello, Ada
Bye, Ada

The program prints Hello, Ada and then Bye, Ada and exits with status 0. Nothing about the call sites changed: p.farewell() resolves to the inherent method exactly as it would have resolved to a trait method, because method lookup considers the type's inherent methods as well as its trait methods. The trait impl is now exactly the trait's list, and the helper survives intact one block down.

The same surplus in a generic trait impl

Generics change nothing about the rule. Convert<T> declares one method; the impl for Convert<usize> supplies it and adds a convenience check, is_empty, that the trait does not declare:

Rust
trait Convert<T> {
    fn convert(&self) -> T;
}

struct Text {
    value: String,
}

impl Convert<usize> for Text {
    fn convert(&self) -> usize {
        self.value.len()
    }

    fn is_empty(&self) -> bool {
        self.value.is_empty()
    }
}

fn main() {
    let text = Text {
        value: String::from("hello"),
    };
    println!("{}", text.convert());
}
Terminal
$ rustc --edition 2021 generic.rs -o generic.bin
error[E0407]: method `is_empty` is not a member of trait `Convert`
  --> generic.rs:14:5
   |
14 | /     fn is_empty(&self) -> bool {
15 | |         self.value.is_empty()
16 | |     }
   | |_____^ not a member of trait `Convert`

error: aborting due to 1 previous error

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

Two details in this message are worth reading. The trait is named as plain Convert, with no type argument: membership is a property of the trait itself, not of one instantiation of it, so no choice of T makes the extra method a member. And the span again covers the whole added method — the compiler is objecting to the item's presence in this block, not to anything inside it.

The repair is the same move as before:

Rust
trait Convert<T> {
    fn convert(&self) -> T;
}

struct Text {
    value: String,
}

impl Convert<usize> for Text {
    fn convert(&self) -> usize {
        self.value.len()
    }
}

impl Text {
    fn is_empty(&self) -> bool {
        self.value.is_empty()
    }
}

fn main() {
    let text = Text {
        value: String::from("hello"),
    };
    println!("{}", text.convert());
    println!("{}", text.is_empty());
}
Terminal
$ rustc --edition 2021 generic_fixed.rs -o generic_fixed.bin
$ ./generic_fixed.bin
5
false

The program prints 5 and then false and exits with status 0: convert() comes from the trait impl, is_empty() from the inherent impl, and both are called on the same value with the same dot syntax.

An extra method in a standard trait impl

The rule binds hardest where the trait is not yours to edit. Display has exactly one required method, fmt. Adding a helper alongside it inside the Display impl fails the same way:

Rust
use std::fmt;

struct Score {
    points: u32,
}

impl fmt::Display for Score {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{} points", self.points)
    }

    fn bonus(&self) -> u32 {
        self.points / 10
    }
}

fn main() {
    let score = Score { points: 250 };
    println!("{score}");
}
Terminal
$ rustc --edition 2021 std_display.rs -o std_display.bin
error[E0407]: method `bonus` is not a member of trait `fmt::Display`
  --> std_display.rs:12:5
   |
12 | /     fn bonus(&self) -> u32 {
13 | |         self.points / 10
14 | |     }
   | |_____^ not a member of trait `fmt::Display`

error: aborting due to 1 previous error

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

The trait is named in full as fmt::Display, and the verdict is identical: bonus is not a member of it. There is no version of this fix that adds the method to the trait — Display is the standard library's trait, its item list is fixed, and every helper a type needs beyond fmt has to live somewhere else.

Default behaves identically. It too has exactly one required method, default, and an impl that adds a describe method next to it reports the same code:

Rust
struct Config {
    retries: u32,
}

impl Default for Config {
    fn default() -> Self {
        Config { retries: 3 }
    }

    fn describe(&self) -> String {
        format!("{} retries", self.retries)
    }
}

fn main() {
    let config = Config::default();
    println!("{}", config.retries);
}
Terminal
$ rustc --edition 2021 std_default.rs -o std_default.bin
error[E0407]: method `describe` is not a member of trait `Default`
  --> std_default.rs:10:5
   |
10 | /     fn describe(&self) -> String {
11 | |         format!("{} retries", self.retries)
12 | |     }
   | |_____^ not a member of trait `Default`

error: aborting due to 1 previous error

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

The fix for both is the inherent-impl move, shown here for the Display case — fmt alone in the trait impl, bonus in a plain impl Score:

Rust
use std::fmt;

struct Score {
    points: u32,
}

impl fmt::Display for Score {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{} points", self.points)
    }
}

impl Score {
    fn bonus(&self) -> u32 {
        self.points / 10
    }
}

fn main() {
    let score = Score { points: 250 };
    println!("{score}");
    println!("{}", score.bonus());
}
Terminal
$ rustc --edition 2021 std_fixed.rs -o std_fixed.bin
$ ./std_fixed.bin
250 points
25

The program prints 250 points — the Display output — and then 25, the bonus computed by the inherent method, and exits with status 0. When the trait belongs to the standard library or to another crate, this is not one repair among several: it is the only direction available, short of defining your own trait, which the extension-trait section below covers.

The typo case: E0407 reported together with E0046

One common cause of this error is not an extra method at all. Here the trait declares both greet and farewell, and the impl means to supply both — but spells the second one farewel, one letter short:

Rust
trait Greet {
    fn greet(&self) -> String;
    fn farewell(&self) -> String;
}

struct Person {
    name: String,
}

impl Greet for Person {
    fn greet(&self) -> String {
        format!("Hello, {}", self.name)
    }

    fn farewel(&self) -> String {
        format!("Bye, {}", self.name)
    }
}

fn main() {
    let p = Person {
        name: String::from("Ada"),
    };
    println!("{}", p.greet());
    println!("{}", p.farewell());
}
Terminal
$ rustc --edition 2021 typo.rs -o typo.bin
error[E0407]: method `farewel` is not a member of trait `Greet`
  --> typo.rs:15:5
   |
15 |       fn farewel(&self) -> String {
   |       ^  ------- help: there is an associated function with a similar name: `farewell`
   |  _____|
   | |
16 | |         format!("Bye, {}", self.name)
17 | |     }
   | |_____^ not a member of trait `Greet`

error[E0046]: not all trait items implemented, missing: `farewell`
  --> typo.rs:10:1
   |
 3 |     fn farewell(&self) -> String;
   |     ----------------------------- `farewell` from trait
...
10 | impl Greet for Person {
   | ^^^^^^^^^^^^^^^^^^^^^ missing `farewell` in implementation

error: aborting due to 2 previous errors

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

This program reports two errors, and reading both is what identifies the cause. The first is E0407: farewel is not a member of trait Greet, with a help line pointing at the similar name — there is an associated function with a similar name: farewell. The second is E0046: farewell itself is missing from the implementation. An extra item and a missing item with near-identical names, reported against the same impl, are one misspelling seen from both sides: the name that was written is not in the trait, and the name that is in the trait was never written.

Neither repair from the earlier sections applies here — moving farewel to an inherent impl would silence E0407 and leave E0046 standing, and the call to p.farewell() in main would still have no trait method to reach. The fix is the spelling:

Rust
trait Greet {
    fn greet(&self) -> String;
    fn farewell(&self) -> String;
}

struct Person {
    name: String,
}

impl Greet for Person {
    fn greet(&self) -> String {
        format!("Hello, {}", self.name)
    }

    fn farewell(&self) -> String {
        format!("Bye, {}", self.name)
    }
}

fn main() {
    let p = Person {
        name: String::from("Ada"),
    };
    println!("{}", p.greet());
    println!("{}", p.farewell());
}
Terminal
$ rustc --edition 2021 typo_fixed.rs -o typo_fixed.bin
$ ./typo_fixed.bin
Hello, Ada
Bye, Ada

The program prints Hello, Ada and then Bye, Ada and exits with status 0. This is also the first check the official guidance for this code names: verify the method name was not misspelled, and that the correct trait was used, before restructuring anything.

The legitimate counterparts: declare it on the trait, or give it its own trait

When the trait is yours, two further repairs keep the method inside a trait impl legitimately. The first is to declare the method on the trait itself. Adding farewell to Greet with a default body makes it a member: impls may then override it, and impls that do not still satisfy the trait through the default:

Rust
trait Greet {
    fn greet(&self) -> String;

    fn farewell(&self) -> String {
        String::from("Bye")
    }
}

struct Person {
    name: String,
}

impl Greet for Person {
    fn greet(&self) -> String {
        format!("Hello, {}", self.name)
    }
}

fn main() {
    let p = Person {
        name: String::from("Ada"),
    };
    println!("{}", p.greet());
    println!("{}", p.farewell());
}
Terminal
$ rustc --edition 2021 trait_default.rs -o trait_default.bin
$ ./trait_default.bin
Hello, Ada
Bye

The program prints Hello, Ada and then Bye — the default body, since this impl does not override it — and exits with status 0. Choose this form when the method genuinely belongs to the trait's contract: every present and future implementor gets it, and adding a defaulted method does not break existing impls of your trait.

The second is the extension-trait pattern: leave the original trait untouched, declare the extra method on a new trait of your own, and implement that trait for the type alongside the first:

Rust
trait Greet {
    fn greet(&self) -> String;
}

trait Farewell {
    fn farewell(&self) -> String;
}

struct Person {
    name: String,
}

impl Greet for Person {
    fn greet(&self) -> String {
        format!("Hello, {}", self.name)
    }
}

impl Farewell for Person {
    fn farewell(&self) -> String {
        format!("Bye, {}", self.name)
    }
}

fn main() {
    let p = Person {
        name: String::from("Ada"),
    };
    println!("{}", p.greet());
    println!("{}", p.farewell());
}
Terminal
$ rustc --edition 2021 extension.rs -o extension.bin
$ ./extension.bin
Hello, Ada
Bye, Ada

The program prints Hello, Ada and then Bye, Ada and exits with status 0. Each impl block now contains exactly its own trait's items. This is also the only trait-shaped option when the first trait belongs to another crate: you cannot add a method to their trait or implement it with extras, but a trait you define can be implemented for the type freely, subject to the usual coherence rules.

Neighboring cases: an extra constant or type is a different error

The same surplus idea applied to the trait's other kinds of item reports different codes, and the difference is in the first line only — the label under the span, not a member of trait Named, is word for word the same. An associated constant the trait does not declare:

Rust
trait Named {
    fn name(&self) -> String;
}

struct Widget;

impl Named for Widget {
    const LABEL: &'static str = "widget";

    fn name(&self) -> String {
        String::from("widget")
    }
}

fn main() {
    let w = Widget;
    println!("{}", w.name());
}
Terminal
$ rustc --edition 2021 extra_const.rs -o extra_const.bin
error[E0438]: const `LABEL` is not a member of trait `Named`
 --> extra_const.rs:8:5
  |
8 |     const LABEL: &'static str = "widget";
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Named`

error: aborting due to 1 previous error

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

The code is E0438, not E0407: a constant that is not a member of the trait. An associated type the trait does not declare:

Rust
trait Named {
    fn name(&self) -> String;
}

struct Widget;

impl Named for Widget {
    type Output = String;

    fn name(&self) -> String {
        String::from("widget")
    }
}

fn main() {
    let w = Widget;
    println!("{}", w.name());
}
Terminal
$ rustc --edition 2021 extra_type.rs -o extra_type.bin
error[E0437]: type `Output` is not a member of trait `Named`
 --> extra_type.rs:8:5
  |
8 |     type Output = String;
  |     ^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Named`

error: aborting due to 1 previous error

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

The code is E0437: a type that is not a member of the trait. E0407 is specifically the method case of this family. All three are repaired the same way in spirit — the item leaves the trait impl, or the trait declaration gains the item — but a search or an error index lookup keyed on the wrong code will land on the wrong page, so read the code in the header, not just the label under the span.

The exact rule: a trait impl may define only the trait's items

The official page for E0407 describes the code in one sentence: a definition of a method not in the implemented trait was given in a trait implementation. Its erroneous example is a trait Foo with one method whose impl adds a second, and its guidance is to verify the method name was not misspelled and the correct trait was used. Its two repairs are the first two in this guide: declare the method on the trait, or move it into an inherent impl on the type.

The Reference states the underlying rule for implementations: a trait implementation must define all non-default associated items declared by the implemented trait, may redefine default associated items defined by the implemented trait, and cannot define any other items. That last clause is E0407. The same page separates the two kinds of implementation — inherent implementations, which associate items directly with the implementing type, and trait implementations — which is why the inherent block accepts the extra method without complaint: it is not drawing from a fixed list.

The Reference's page on traits supplies the default-body half of the trait-declaration repair: a trait function that defines a body acts as a default for any implementation that does not override it, while a function declared with a semicolon in place of a body must be defined by the implementation. Adding the extra method with a body is therefore the non-breaking way to grow your own trait; adding it without a body makes it required, and every existing impl then owes it.

The standard library pages pin down the two standard traits used above. Display declares a single required method, fmt, and Default declares a single required method, default — in both cases the complete list an impl may draw from, which is why one helper method beside either of them is already a surplus.

The fixes, ranked

  • First, check the spelling and the trait. If a required item of the same trait is also reported missing (E0046) and the names are near-identical, the extra method is a typo: correct the name in the impl, and both errors clear together.
  • Second, for a genuinely extra method: move it to an inherent impl block on the same type — impl Type with no trait named. The body and the call sites do not change. This is the repair when the trait is the standard library's or another crate's, and the default repair for your own traits too.
  • Third, if the trait is yours and the method belongs to its contract: declare the method on the trait, with a default body if existing implementors should keep compiling without providing it.
  • Fourth, if the method should travel as an interface — callable through a trait bound, or offered for types you do not own: declare it on a new extension trait of your own and implement that trait next to the original impl.
  • Do not delete the extra method just to silence the error, and do not leave it in the trait impl behind an allowance or a comment. The method was written because something calls it or will; every repair above keeps it working, and deletion is the one outcome that turns a misplaced item into missing behavior.

Which fix for which cause

Cause Message Fix
Extra method in an impl of your own trait E0407, farewell not a member of Greet Move it to impl Person
Extra method in a generic trait impl E0407, is_empty not a member of Convert Move it to an inherent impl
Extra method in a Display impl E0407, bonus not a member of fmt::Display Move it to impl Score
Extra method in a Default impl E0407, describe not a member of Default Move it to an inherent impl
Required method under a misspelled name E0407 plus E0046, similar-name help Correct the spelling in the impl
Method belongs on your own trait E0407 in every impl that adds it Declare it on the trait, with a default body
Method needs its own interface E0407 in the foreign trait's impl Declare an extension trait and implement it
Extra associated constant in a trait impl E0438, not a member of the trait Move it out, or declare it on the trait
Extra associated type in a trait impl E0437, not a member of the trait Move it out, or declare it on the trait
## Checklist
  • Read the label under the span first. not a member of trait ... names the method and the trait whose list it is absent from — compare the impl's items against that trait's declaration, item by item.
  • Check for the paired error before moving anything. E0046 naming a similar item as missing, or a similar-name help line, means a misspelling: fix the name, not the structure.
  • Confirm which trait the impl was meant for. A method written into the wrong trait's impl block — a helper for one trait placed in another's — is the same surplus from the compiler's side; move it to the impl it belongs in.
  • If the trait is not yours, do not plan around editing it. A standard or foreign trait's list is fixed: the inherent impl, or your own extension trait, are the routes.
  • If the trait is yours, decide whether the method is part of its contract. Contract methods go on the trait (with a default body to spare existing implementors); type-specific helpers go in the inherent impl.
  • Watch the neighboring codes. The identical surplus as an associated constant is E0438 and as an associated type is E0437; only the method case is E0407.
  • After the fix, confirm the method is still called the way it was. The fixed programs here print both the trait method's result and the moved method's result, from unchanged call sites.

Sources

  • Rust Compiler Error Index, E0407 — for E0407 being a definition of a method not in the implemented trait given in a trait implementation, for verifying the method name was not misspelled and the correct trait was used, and for the two repairs of declaring the method on the trait and moving it to an inherent impl.
  • The Rust Reference, Implementations — for a trait implementation having to define all non-default associated items, being allowed to redefine default items, and being unable to define any other items, and for the distinction between inherent and trait implementations.
  • The Rust Reference, Traits — for a trait function with a body acting as a default for implementations that do not override it, and for a function declared without a body having to be defined by the implementation.
  • std, Display — for Display declaring the single required method fmt.
  • std, Default — for Default declaring the single required method default, and for it being a trait for giving a type a useful default value.

Keep Exploring