Skip to content
ZOLO / TE302 Type · error

unknown trait

A trait bound, `impl` block, or `where` clause references a trait the compiler cannot find.

Why this fires

An impl <Trait> for <Type> names a trait that doesn't exist — neither a trait declared in the program nor one of the known standard traits (Iterator, Eq, Ord, Default, ...). Usually a typo.

trait Iterable { fn next(self) -> int }

struct V {}
impl Iterabe for V {
//   ^^^^^^^ error[TE302]: unknown trait 'Iterabe' in `impl ... for V`. Did you mean 'Iterable'?
    fn next(self) -> int { return 0 }
}

Fix it

Trust the "did you mean?" suggestion and fix the spelling:

impl Iterable for V {
    fn next(self) -> int { return 0 }
}

See also

  • TE822 — the same "unknown trait" check for a generic parameter's trait bound.
  • TE825 — an impl is missing one of the trait's required methods.
  • /docs/data-structures#traits — declaring and implementing traits.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br