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

E0478: Linear value discarded

CodeCategoryStability
E0478Struct and enumPermanent

Explanation

A discarded expression result is dropped rather than transferred to a consumer. Rue rejects discarding a value whose type carries a linear obligation, including with a bare expression statement or let _ = value;, because an implicit drop is not consumption. @drop(value) is the explicit-discard operation and consumes its operand.

Likely cause

A function call or other expression produces a linear value but its result is ignored, or a wildcard let was used in an attempt to consume it. Pass or return the value, bind and consume it, or use @drop when intentional destruction is the desired consumption.

Examples

Discard a linear value with a wildcard binding

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

Explicitly drop the linear value

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

References