Skip to content

#2942, #2939: the str .clone() and the explicit &x at a &T parameter go (2233 sites, census-driven) - #3027

Merged
ehartford merged 4 commits into
mainfrom
ceremony-sweeps
Nov 3, 2026
Merged

ehartford merged 4 commits into
mainfrom
ceremony-sweeps

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Two mechanical ceremony sweeps from the 2026-11-02 audit, each driven by the census's Sema-backed site listing (with run tools/ceremony_census.w --sites PATTERN) through the new tools/strip_census_sites.w, never by a regex.

#2942, str-clone (layer 1). D111: a str is a value; code using str never needs .clone(). 476 of the 483 sites rewritten (50 files); the census's lexical clone-call count in src falls 544 → 64. Seven sites keep .clone() and are one D111 gap, filed as #3026: an unannotated let of a str field (or a local record's str field) binds a view of the place (field_let_binds_as_view; MIR alias-binds it), so a later self mutation or a consume of the record is refused, and a str global read in value position is refused as "cannot move out of global". Its fix is its own layer (a str place let takes the str by the annotated form's copy path; reject_move_out_of_global exempts str); the seven are re-swept after.

#2939, ref-at-ref-param (layer 2). §3.8 auto-references at a &T parameter. 1757 sites: 1754 by the tool, three in lib/std/regex.w by line (the embedded copy's byte offsets differ from the file's there). Two keep the &: &List.new() passed to a &List[T] parameter, where the written & is what lets the untyped empty literal take the parameter's element type (auto-ref of the bare temporary is refused "argument has type List, expects &List[PyVal]"). Either the census should skip a & on an untyped literal or auto-ref should infer the literal from the parameter as & does; your call which.

Iterate tier: the swept tree builds (:dev), a behavior smoke passes, census diff ok at each layer. No fixtures of their own: a sweep changes no behavior, and the gate plus battery are the proof. Draft until the battery is green.

@ehartford

Copy link
Copy Markdown
Contributor Author

The first gate run was red only at abi-hash-check: the sweep touched src/TypeLayout.w (an ABI-keyed source) with spelling-only changes (&x → x at &T parameters). The hash is re-recorded in docs/with-abi.sha256 in the top commit (no convention changed, so no WITH_ABI_VERSION bump); gate re-running.

@ehartford

Copy link
Copy Markdown
Contributor Author

Gate green on the pre-rebase tree (522 s, seed-driven; the second run was red only on the census: removing .clone() left three var t: str = text annotations that the census counts as ceremony — the annotations are dropped too). Rebased cleanly onto main ec0f3ae (106e36c); battery running.

@ehartford

Copy link
Copy Markdown
Contributor Author

Battery red on cli-selfhost-build-w-tests (build-w-workspace-parallel-stress, a double free): root cause is #3032 — ComptimeValue keeps its own text_refs count for its text and its drop frees the text under a str copy, so the nine value.text.clone() the sweep removed in ComptimeEval.w/BuildGraphMaterialize.w were deep copies the convention requires, not ceremony. Chain by the route (reporter breakpoint with -r, then the trap pair under lldb with WITH_BUILD_JOBS=1 so the parallel case replays): allocated by comptime_value_clone in capability_args, freed by ComptimeValue's drop in eval_buildctx_capability_method, freed again by the generated-source record in materialize_build_graph_from_comptime. The nine clones are restored in a third commit; gate re-running, then rebase onto main and battery.

Eric Hartford added 4 commits November 3, 2026 16:23
D111: a str is a value; passing one copies (a count increment) and code
using str never needs `.clone()`. The compiler and lib/std still spelled
it. `tools/strip_census_sites.w` applies a rewrite at the sites the
ceremony census lists (`--sites str-clone`, Sema-backed, never a regex):
for str-clone it drops the trailing `.clone()`; it also knows
ref-at-ref-param (drops a leading `&` at a `&T` parameter) for the next
sweep. 483 sites in 50 files rewritten; the census' clone-call count in
src falls 544 → 64.

Seven sites keep their `.clone()`: an unannotated let of a str field or
record field binds a view of the place (MIR alias-binds it), and a str
global read in value position is refused as a move, so removing the
clone fails to compile. That is one D111 gap, filed as #3026 with the
sites; its fix is its own layer, after which the seven are re-swept.
…ameter goes (1757 sites)

§3.8: `peek(x)` where `peek` takes `&T` auto-references; the written `&`
teaches the idiom the mission says is wrong. `tools/strip_census_sites.w
ref-at-ref-param` drops the leading `&` at every site the census lists
(Sema-backed: an explicit `&x` at a `&T` parameter), 1754 by the tool
and three in lib/std/regex.w by line (the embedded copy's byte offsets
differ from the file's for those).

Two sites keep the `&`: `&List.new()` passed to a `&List[T]` parameter
(RecipeInterp.w, CodegenDispatch.w). The written `&` is what lets the
untyped empty literal take the parameter's element type; auto-ref of
the bare temporary is refused ("argument has type List, expects
&List[PyVal]"). Either the census pattern should skip a `&` on an
untyped literal, or auto-ref should infer the literal from the
parameter as `&` does.
…s own text_refs count owns it, not the str's holder count
…me symbols are module-mangled on the release binary); the trap pair needs equal env sets and WITH_BUILD_JOBS=1 for a parallel program
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery GREEN on `356ce1e3c` (rebased onto `main` `32b608a64`), wall 313s; UAT 12 pass / 1 skip (`raylib_spiral_windows`), `raylib_spiral` and `sdl` both green. Note: the 6 non-`ComptimeValue` str `.clone()` sites in `src/` (#3026 shape) stay seed-bound until a post-#3028 seed is pinned (the pinned seed compiles `src/` and refuses str global reads / unannotated str field lets before #3028).

@ehartford
ehartford marked this pull request as ready for review November 3, 2026 21:38
@ehartford
ehartford merged commit 2e34f1d into main Nov 3, 2026
@ehartford
ehartford deleted the ceremony-sweeps branch November 3, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant