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

E0433: Empty struct

CodeCategoryStability
E0433Struct and enumPermanent

Explanation

An anonymous struct declaration contains neither fields nor methods. Such a declaration has no observable structure or behavior and is rejected; this rule does not apply to named zero-sized structs or anonymous structs that declare methods.

Likely cause

A comptime type producer returned a bare struct {} placeholder. Add a field or method to the anonymous type, or declare a named empty struct when a named zero-sized marker type is intended.

Examples

Produce an empty anonymous struct

fn Empty() -> type { struct {} }
fn main() -> i32 {
    let E = Empty();
    0
}

Give the anonymous struct behavior

fn Utility() -> type {
    struct { fn answer() -> i32 { 42 } }
}
fn main() -> i32 {
    let U = Utility();
    U.answer()
}

References