Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0304: Missing associated type

CodeCategoryStability
E0304SemanticPermanent

Explanation

An interface requires a type-valued associated constant for which the conforming type has no public associated type declaration.

Likely cause

The type omitted the associated type, spelled its name differently, or did not expose it publicly. Add a matching pub const declaration naming the associated type.

Examples

Missing associated type

Requires --preview interfaces.

interface HasElement { const Element: type; }
struct Value is HasElement {}
fn accept(comptime T: HasElement, borrow x: T) {}
fn main() { accept(Value, borrow Value {}); }

Declare the public associated type

Requires --preview interfaces.

interface HasElement { const Element: type; }
struct Value is HasElement { pub const Element = i64; }
fn accept(comptime T: HasElement, borrow x: T) {}
fn main() { accept(Value, borrow Value {}); }

References