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

E0400: Missing fields

CodeCategoryStability
E0400Struct and enumPermanent

Explanation

A struct value was constructed without an initializer for every field declared by its type, or a struct pattern (preview feature struct_patterns) names fewer fields than its type declares. A struct pattern has no rest form: it must name every field, so a field added to the type is reported at every pattern that does not bind it.

Likely cause

A field was omitted from the struct literal or pattern, often after the struct definition gained a new field. Supply each declared field exactly once; order does not matter. In a pattern, bind the field or discard it with field: _.

Examples

Omitted struct field

struct Point { x: i32, y: i32 }
fn main() -> i32 {
    let point = Point { x: 10 };
    point.x
}

Initialize every field

struct Point { x: i32, y: i32 }
fn main() -> i32 {
    let point = Point { x: 10, y: 32 };
    point.x + point.y
}

References