Issue #1139: A match over a place inside a mut parameter moves the part an arm changes in place (E0507)

Open and answer this issue on GitHub.

ready · opened 2026-11-01 · updated 2026-11-01 · 0 comments

Found by the r3c-a builder (report docs/briefs/bugs/r3c-a-taking-arms.md.report.md). It blocks chunk 2 of the type_rules move (wip/r3c-type-rules-chunk2, tr_rewrite_item: match item.node { Item::Impl { ref target, methods, .. } lowers without &mut).

Probe:

enum Node { Leaf(i64), Many { items: Vec[i64], tag: String } }
struct Held { node: Node }
fn bump(mut n: i64) { n = n + 1 }
fn grow(mut h: Held) {
    match h.node {
        Node::Many { items, .. } => { for mut one in items { bump(one) } },
        else => {}
    }
}

The lowered Rust is match h.node { … } and rustc refuses it with E0507 (cannot move out of h.node). It should be match &mut h.node (the arm changes items in place).

To build:

Part of #125

Back to Open Issues