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

E0406: Linear value not consumed

CodeCategoryStability
E0406Struct and enumPermanent

Explanation

A value carrying a linear obligation reached the end of its scope without being consumed.

Likely cause

A binding of a declared-linear type, or an aggregate containing a linear value, was left live. Move it into a by-value consumer, return it to transfer the obligation, consume its declared-linear value through a field projection, or explicitly drop it when @drop is appropriate.

Examples

Unconsumed linear value

linear struct Token { value: i32 }
fn main() -> i32 {
    let token = Token { value: 42 };
    0
}

Pass the value to a consumer

linear struct Token { value: i32 }
fn consume(token: Token) -> i32 { token.value }
fn main() -> i32 {
    let token = Token { value: 42 };
    consume(token)
}

References