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

E0499: Container element is linear

CodeCategoryStability
E0499Struct and enumPermanent

Explanation

An owning growable container can run ordinary drop glue for each live element, but it cannot yet propagate and enforce a linear element's exactly-once consumption obligation. @require_droppable(T) therefore rejects a linear element type at container instantiation rather than allowing elements to leak or be implicitly dropped.

Likely cause

A generic owning container guarded by @require_droppable was instantiated with a linear type. Use a non-linear element type, choose a representation whose API explicitly transfers every element, or wait for container/element multiplicity propagation to be designed.

Examples

Instantiate a droppable-gated container with a linear element

fn Container(comptime T: type) -> type {
    @require_droppable(T);
    struct { value: T }
}
linear struct Token { value: i32 }
const Bad = Container(Token);
fn main() -> i32 { 0 }

Use a non-linear container element

fn Container(comptime T: type) -> type {
    @require_droppable(T);
    struct { value: T }
}
const Good = Container(i32);
fn main() -> i32 {
    let value = Good { value: 42 };
    value.value
}

References