Skip to content
ZOLO / TE481 Type · error

associated type is missing or cannot be resolved unambiguously

A trait declares an associated type with no default, but an implementation does not define it, so the compiler cannot project `Self::Item` (or another associated name) from that implementation.

Why this fires

A trait declares an associated type without a default, but an implementation does not define it. The compiler cannot project Self::Item (or another associated name) from that implementation.

trait Source {
    type Item
}

struct Numbers {}
impl Source for Numbers {
    // error[TE481]: missing associated type `Item`
}

Fix it

Define the associated type in the impl:

impl Source for Numbers {
    type Item = int
}

An associated type with a trait-level default does not have to be repeated.

See also

  • TE480 — associated type violates a bound.
  • TE305 — duplicate or undeclared associated item.
  • specs/gradual-type-precision.html.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br