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
One InternPool and one AstPool per compilation: phases borrow &InternPool/&AstPool, the pool .clone() sites (#2449's allowance) go away #2523
#2449 (closed) made InternPool and AstPool counted handles: since then a type that keeps a pool stores pool.clone(), the explicit second-holder spelling. build/ceremony-allowances.tsv grants these under clone-call src (bar 537 → ceiling 558) with the note that "the single-owner restructure (one pool per compilation, every phase borrowing it) removes them". Fix shape step 1 of #2449 — one owner per compilation, everyone else borrows &InternPool / &AstPool — has no open issue. This is that issue.
Where the clones are (38 pool/intern-named .clone() sites in src/, rough lexical count):
Representative: Zcu { pool: pool.clone(), frontend_pool: pool, … } (src/compiler/Zcu.w:149), self.pool = sema.pool.clone() (Zcu.w:533), return pool.clone() (Compilation.w:1093,1097), and emit_intern = … last_sema.pool.clone() else: self.zcu.pool.clone() (Compilation.w:1766). Several of these exist because Zcu holds two or three pools (pool, frontend_pool, typed_pool_cache) that are swapped as phases hand the pool along.
Fix
One InternPool and one AstPool per compilation, owned by Compilation/Zcu (and by the LSP document for with lsp).
Parser, Sema, MirLower, Codegen, the backends and the analyze tools take &InternPool / &AstPool and do not store a handle; a phase that needs the pool for its lifetime borrows it from the owner instead of holding a count.
The pool swaps in Zcu (set_pool, set_frontend_pool, sync_from_sema, typed_pool_cache) are replaced by one pool that the phases mutate in turn, or the case for keeping two distinct pools is written down.
Done when: no InternPool/AstPool.clone() remains in src/ outside a site that genuinely needs an independent second holder (each named in a comment), the allowance is gone, with lsp's RSS stays flat over repeated reparses (#2449's pin), and the drop audit is unchanged.
Related: #2449, D111/D120 (a counted handle is the explicit second-holder form), #2519 (the census section that lists these as intentional until this lands).
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced: not started. build/ceremony-allowances.tsv still grants clone-call src 537 → 558 for the pool clones, with the note that "the single-owner restructure (one pool per compilation, every phase borrowing it) removes them".
Step 1 merged (#3605): Zcu holds one intern pool. Its third holder (frontend_pool, read by nothing) and set_pool (no callers) are gone, and the two swaps that took a pool back from Sema now only require it is the same pool. That requirement never fires in the stage chain or the battery, so the swaps were no-ops: every phase already interns into the compilation's pool.
Left, in the order I would take it:
Zcu.typed_pool_cache and Compilation.active_pool: the same question for the AST pool (it already has require_same_storage).
The backends' if sema has symbols: sema.pool.clone() else: self.pool.clone() choices (Backend.with, 8 sites): with one pool these are one expression.
The fields that keep a handle for a phase's lifetime (Parser, Resolve, Sema, MirLower, Codegen, CCodegen, AsyncLower, ComptimeEval): the borrow half of the issue.
Steps 2 and 3 merged (#3606, #3607). The backends' eight either-pool choices are two helpers that return the compilation's own pools, and active_pool is a check. Each replaced swap or choice was guarded by a same-storage requirement that never fired in the stage chain or the battery, so there is one intern pool and one tree per compilation in fact; what remains is spelling it that way.
Clone sites named pool/ast/intern/tree in src/: 39 → 27.
Left: the fields that keep a handle for a phase's lifetime (Parser, Resolve, Sema, MirLower, Codegen, CCodegen, AsyncLower, ComptimeEval, Lsp), which is the borrow half of the issue, and then the #2449 allowance line and its bar.
Activity
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced: not started.build/ceremony-allowances.tsvstill grantsclone-call src 537 → 558for the pool clones, with the note that "the single-owner restructure (one pool per compilation, every phase borrowing it) removes them".post-release: a compiler-wide ownership refactor.
One intern pool per compilation, step 1: the Zcu's dead third holder …
ehartford commentedon Nov 25, 2026
Step 1 merged (#3605):
Zcuholds one intern pool. Its third holder (frontend_pool, read by nothing) andset_pool(no callers) are gone, and the two swaps that took a pool back from Sema now only require it is the same pool. That requirement never fires in the stage chain or the battery, so the swaps were no-ops: every phase already interns into the compilation's pool.Left, in the order I would take it:
Zcu.typed_pool_cacheandCompilation.active_pool: the same question for the AST pool (it already hasrequire_same_storage).if sema has symbols: sema.pool.clone() else: self.pool.clone()choices (Backend.with, 8 sites): with one pool these are one expression.One pool per compilation, step 2: a backend run holds the compilation…
One pool per compilation, step 3: the stages after the check read the…
ehartford commentedon Nov 25, 2026
Steps 2 and 3 merged (#3606, #3607). The backends' eight either-pool choices are two helpers that return the compilation's own pools, and
active_poolis a check. Each replaced swap or choice was guarded by a same-storage requirement that never fired in the stage chain or the battery, so there is one intern pool and one tree per compilation in fact; what remains is spelling it that way.Clone sites named
pool/ast/intern/treeinsrc/: 39 → 27.Left: the fields that keep a handle for a phase's lifetime (Parser, Resolve, Sema, MirLower, Codegen, CCodegen, AsyncLower, ComptimeEval, Lsp), which is the borrow half of the issue, and then the #2449 allowance line and its bar.
Wave 4: []mut T stages 2-3 (#604), borrow &InternPool/&AstPool across…