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
Ruling: docs/decisions.md D34 ('C absolutely — if we can make ++ as efficient as StringBuilder we should do it and remove complexity').
Why With can do what Rust/Go can't
They need a separate builder type because they cannot prove the accumulator is unaliased at the append site. With's ownership model proves unique ownership statically — s = s ++ x (and s ++= x) on a uniquely-owned base is exactly the condition for growing the buffer in place.
Components
str capacity awareness: in-place growth needs to know the allocation's usable size — either the allocator's block-size query (rt_alloc knows) or a capacity field in the str payload header. Decide with a micro-benchmark; fixpoint-sensitive either way.
codegen/runtime fast path: base ++ x where base is a uniquely-owned local/place at its last use before reassignment to itself → reserve+memcpy append instead of fresh-alloc+copy. The unique-ownership condition comes from the move checker's existing facts.
DELETE the loop-accumulator lint (warn_loop_string_concat_accumulation) — the natural spelling becomes the fast spelling; a lint herding users from the ergonomic form to a ceremonial one is the mission's named anti-pattern.
retire StringBuilder from the user surface (docs, spec §29 mentions, examples); it may survive internally until callers migrate.
comptime evaluator: the same fast path in the evaluator's string ops (build actions accumulate manifests — the test-green 77s anomaly's home).
perf proof: before/after on the accumulation micro-bench + the evaluator-heavy build actions; baselines to docs/perf.
Interim (landing first, subsumed later)
[x-in-flight] StringBuilder.push_str becomes reserve+bulk-copy instead of one bounds-checked push PER BYTE (~100x native; far worse under the comptime evaluator where each byte was several interpreted steps).
to_str() zero-copy when uniquely owned (buffer adoption instead of final copy) — pending a look at str payload layout.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): needs a ruling: two decisions now point opposite ways. D34 (2026-09-02) rules that ++ accumulation becomes as efficient as a builder, StringBuilder retires and the accumulator lint is deleted. D111 (2026-10-08) rules that str is an immutable, shared, counted buffer and that "Text that is built or edited goes through a builder type that produces a str." Today the lint fires and recommends StringBuilder:
warning: string concatenation with ++ inside a loop repeatedly copies the accumulator; use StringBuilder or collect pieces and concatenate once
The question: does D111 supersede D34-C (the builder stays and the lint is the guidance), or does D34-C stand on top of D111 (a uniquely held buffer at its last use appends in place, so s = s ++ x is amortized and the builder and lint go)?
Ruled, 2026-11-18 (D219): D34-C stands and D111's sentence describes the implementation; StringBuilder leaves the prelude and stays in std.string; the lint stays for non-append shapes with advice that works, and also covers an accumulator that is not uniquely held, where provable (every append copies then).
Activity
sema: raw-mut of a mut-receiver field does not seed ESCAPE_VALUE (#919 …
rt/std: StringBuilder.push_str is one grow-to-fit + one memcpy (#919 …
runtime: declare with_vec_append_bytes in the emit-c header (#919)
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): needs a ruling: two decisions now point opposite ways. D34 (2026-09-02) rules that++accumulation becomes as efficient as a builder,StringBuilderretires and the accumulator lint is deleted. D111 (2026-10-08) rules thatstris an immutable, shared, counted buffer and that "Text that is built or edited goes through a builder type that produces a str." Today the lint fires and recommendsStringBuilder:The question: does D111 supersede D34-C (the builder stays and the lint is the guidance), or does D34-C stand on top of D111 (a uniquely held buffer at its last use appends in place, so
s = s ++ xis amortized and the builder and lint go)?ehartford commentedon Nov 19, 2026
Ruled, 2026-11-18 (D219): D34-C stands and D111's sentence describes the implementation;
StringBuilderleaves the prelude and stays instd.string; the lint stays for non-append shapes with advice that works, and also covers an accumulator that is not uniquely held, where provable (every append copies then).D218, D219 and D220 recorded: Eric's rulings of 2026-11-18 on #615, #919
The accumulator lint names no builder, and warns when a variable hold…