Issue #2492: Sharing::note looks its key up once, with entry(key).or_insert_with moving ty

Open and answer this issue on GitHub.

ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments

Part of #973 Part of #950 After #973

What it is

The site that found #973: Sharing::note in crates/nikaia-std/src/compiler/sharing.nika does if !self.handles.contains_key(key) { self.handles.insert(key.clone(), Handle { .., ty: ty, .. }) }, a double lookup, because a lambda moving the owned parameter ty into or_insert_with was refused with NK2105. With #973 built (ADR-lambdas-1 D1, D2), it becomes one entry(key).or_insert_with(...) that moves ty, with no copy and no second lookup.

To build

  1. Convert Sharing::note in crates/nikaia-std/src/compiler/sharing.nika to one entry(key).or_insert_with(...) that moves ty (commit says Part of #950). Its existing tests stay unchanged.

Done when

Sharing::note makes one entry(key).or_insert_with(...) call that moves ty, with no contains_key before it, and the tests that run the sharing pass are unchanged; the commit carries the Fixes line for this issue.

Files

crates/nikaia-std/src/compiler/sharing.nika (and its lowered output).

Split from #973 by Claude Code

Back to Open Issues