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

E0443: Linear value not consumed on all paths

CodeCategoryStability
E0443Struct and enumPermanent

Explanation

A linear value is consumed along some reachable control-flow paths but remains live along others that leave its scope. Linear obligations must be discharged on every path; otherwise an unconsumed path would implicitly drop the value.

Likely cause

An if, match, loop, or early exit consumes the value in only some alternatives. Restructure the control flow so every path that leaves the scope passes, returns, or otherwise moves the linear value to a consumer.

Examples

Consume a linear value in only one branch

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

Consume the linear value in every branch

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

References