Skip to content
Latchkey

Rust E0407 "method is not a member of trait" in CI

A trait impl block defines a method whose name does not appear in the trait. rustc rejects it because trait impls may only implement methods the trait declares.

What this error means

The compiler reports error[E0407]: method foo is not a member of trait Bar`` at the offending impl. It is deterministic across runs.

cargo
error[E0407]: method `renderr` is not a member of trait `Widget`
 --> src/ui.rs:20:5
   |
20 |     fn renderr(&self) -> String { String::new() }
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Widget`

Common causes

Typo in the method name

A misspelled method in the impl (renderr vs render) does not match any trait method, so it is treated as a non-member.

Stale trait or impl after a rename

The trait method was renamed or removed but the impl still carries the old name, so the impl no longer lines up with the trait.

How to fix it

Match the impl method to the trait

  1. Open the trait definition and compare its method names to the impl.
  2. Rename the impl method to the exact trait method name.
  3. If you meant to add a new helper, move it into a separate inherent impl block, not the trait impl.
src/ui.rs
impl Widget for Button {
    fn render(&self) -> String { /* ... */ }
}

How to prevent it

  • Keep trait and impl method names in sync when renaming.
  • Put non-trait helpers in inherent impls, not the trait impl block.
  • Run cargo check after editing trait signatures.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →