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

E0430: Borrow inout conflict

CodeCategoryStability
E0430Struct and enumPermanent

Explanation

A call creates overlapping shared and exclusive loans of the same root variable. Rue's law of exclusivity permits either one inout access or any number of borrow accesses to a root. A nested inout during argument evaluation conflicts when the enclosing loan is shared or its operand has already been materialized as a view; an address-passed enclosing inout may instead observe the sequenced mutation.

Likely cause

One argument borrows a variable while another passes that variable, one of its projections, or a conflicting nested access inout. Separate the accesses into distinct calls, preserve any needed read in a value first, or operate on distinct root variables.

Examples

Borrow and mutate fields of one root

struct Pair { left: i32, right: i32 }
fn copy_into(borrow source: i32, inout target: i32) { target = source; }
fn main() -> i32 {
    let mut pair = Pair { left: 42, right: 0 };
    copy_into(borrow pair.left, inout pair.right);
    pair.right
}

Share the same root read-only

fn add(borrow a: i32, borrow b: i32) -> i32 { a + b }
fn main() -> i32 {
    let value = 21;
    add(borrow value, borrow value)
}

References