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

E0425: Inout non lvalue

CodeCategoryStability
E0425Struct and enumPermanent

Explanation

An explicit inout argument or ordinary inout self receiver does not name mutable caller-owned storage. Exclusive access must write back through an addressable place: a mutable variable, field, or array element.

Likely cause

A literal, arithmetic expression, constant, or call result was passed inout or used directly as an inout self receiver. Bind the value to a mutable local first, or use an existing mutable place whose changes should remain visible after the call.

Examples

Pass a computed value inout

fn increment(inout value: i32) { value = value + 1; }
fn main() -> i32 {
    increment(inout 40 + 2);
    0
}

Use a mutable place

fn increment(inout value: i32) { value = value + 1; }
fn main() -> i32 {
    let mut value = 41;
    increment(inout value);
    value
}

References