You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An owned str temporary interpolated in an f-string leaks: f"{t.slice(0, 2)}" #1390
fn check(t: &str):
print(f"{t.slice(0, 2)}")
fn main:
let s = "abc" ++ "def"
check(&s)
with run --debug-alloc (installed v0.15.2.1 and origin/main 8c859a7): prints ab, then debug-alloc: leak count=1.
Binding first (let h = t.slice(0, 2) then f"{h}") is leak count=0.
Expected: the interpolated call result is a statement temporary and is dropped after the f-string is built.
The owned result of a ??/unwrap_or join interpolated directly is never dropped. Found while writing the D60 debug-alloc fixture (test/debug_alloc/da_d60_tail_assignment_moves.w binds the joined value first).
Activity
ehartford commentedon Sep 23, 2026
Same leak through the eliminators, on origin/main 5848ae9 (stage1 built from it),
run --debug-alloc:f"{plain_opt() ?? "none".clone()}"f"{plain_opt() ?? "none"}"f"{none_opt() ?? "none".clone()}"f"{plain_opt().unwrap_or("none".clone())}"let x = plain_opt() ?? "none".clone()thenf"{x}"print(plain_opt() ?? "none".clone())f"{plain()}"withfn plain -> strThe owned result of a
??/unwrap_orjoin interpolated directly is never dropped. Found while writing the D60 debug-alloc fixture (test/debug_alloc/da_d60_tail_assignment_moves.wbinds the joined value first).ehartford commentedon Sep 23, 2026
Also through
.await(origin/main 5848ae9 stage1,run --debug-alloc):prints
hi!,leak count=1.let v = name().awaitthenprint(v)isleak count=0.MIR: an owned temporary in an f-string hole is a statement temp, drop…
MIR: an owned temporary in an f-string hole is a statement temp, drop…