for w in kept over a held list of views fails in rustc: “cannot move out of *w”Open and answer this issue on GitHub.
bug, ready · opened 2026-11-28 · updated 2026-11-28 · 0 comments
Found while “Does a frame or task keep holding buffers whose views died cost anything” (#2847), by its builder.
On develop 3c5592cd, a list of views that drops entries in the loop (ADR-tether-v1 D12, lowered as Vec<tether::Held>), then walked:
fn main() {
let mut kept: Vec[String] = []
for i in 0..<100 {
let text = "word" + i.to_text() + " rest"
let w = text.split(" ").next() ?? ""
kept.push(w)
if kept.len() > 8 { kept.remove(0) }
}
let mut n = 0
for w in kept { n = n + w.len() }
println(n)
}
Expected: prints the summed lengths of the last 8 words (48).
Actual: error[NK1343]: Internal compiler error., rustc: “cannot move out of *w”, both for a walk inside and after the loop; for w in kept.iter() works.
Suspected, not checked: emit_stmt_loop_copies (emit_stmt.nika, about line 1712) writes let w = *w; because copied_view_bindings counts a text view as Copy without asking whether the list is held (Held is not Copy).
develop (adjust it until it reaches the lowering of D12 if the builder’s text differs).Held, not by copy. Test: tests/compiler/tests/a_held_list_is_walked_by_for.nika, the probe, .stdout.The test passes and failed before the fix; that commit carries Fixes #N. A Found: line per finding.
emit_stmt.nika, the plan it asks, their lowered files.
Facts: Lowering and lower-std, Checker and views