Open and answer this issue on GitHub.
ready · opened 2026-11-01 · updated 2026-11-01 · 0 comments
The builder of the focus rotation (scripts/drive.nika --focus) found this on 2026-11-01. It worked around it in drive.nika by passing text instead of text.clone(). Once this is fixed, that call should go back to the plain form.
A function returns the words of its String parameter, made with split().collect(), so the result borrows from the parameter. The function is called with the temporary text.clone(). Check accepts this, but the lowered Rust fails with “temporary value dropped while borrowed”. Either the result has to own its words, or the argument has to live long enough.
fn words_of(text: String, key: String) -> Vec[String] {
for line in text.split("\n") {
let w = line.trim().split(" ").collect()
if w.len() > 1 && w[0] == key {
return w
}
}
let n: Vec[String] = []
return n
}
fn current(text: String) -> String {
let w = words_of(text.clone(), "current")
if w.len() > 1 {
return w[1].clone()
}
return text
}
fn main() {
println(current("block 3\ncurrent converter 0"))
}
Expected output: converter. Actual: rustc E0716 (temporary value dropped while borrowed).
tests/compiler/tests/words_from_a_temporary.nika with its .stdout, failing on the unfixed binary. Then put text.clone() back in the place in scripts/drive.nika that the focus builder changed.