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

E0208: Move while call loaned

CodeCategoryStability
E0208SemanticPermanent

Explanation

One call both loaned a non-Copy value through borrow or inout and tried to move that same value into another by-value argument.

Likely cause

Two arguments are rooted in the same binding, with one passed by reference and the other consuming the value. The loan spans the entire call, so the move would leave it referring to moved-from storage.

Examples

Move and loan in one call

struct Resource { id: i32 }
fn use_both(inout left: Resource, right: Resource) {}
fn main() {
    let mut resource = Resource { id: 1 };
    use_both(inout resource, resource);
}

Use distinct owners

struct Resource { id: i32 }
fn use_both(inout left: Resource, right: Resource) {}
fn main() {
    let mut left = Resource { id: 1 };
    let right = Resource { id: 2 };
    use_both(inout left, right);
}

References