Skip to content

spec: six rulings of 2026-09-22 (destructor boundary, facade destroyers, Sender Clone, print over Display, examples policy) — D55 - #1277

Merged
ehartford merged 2 commits into
mainfrom
spec-rulings-drop-sender-print
Sep 22, 2026
Merged

ehartford merged 2 commits into
mainfrom
spec-rulings-drop-sender-print

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Drafted spec words for the six rulings (your blessing of the exact words = merge; edit in place where the register is off):

  • §2.5.1 — the boundary sentence you stated: "The only way to skip a destructor is a spelling that is visible at the type's own boundary." + one sentence tying §9.7.
  • §9.7 Patterns and Drop — error outside the type's own move fns with fix-its let t = r / r.field; inside them the destructure is the disarm and must be total (partial R { fd, .. } errors naming the unstated fields); one rule for let/match/if let.
  • §16.2b.3 — destroys without drop is a compile error (name the unary destroyer as drop); void * destroyer accepts object-pointer representations only (no function pointers, no by-value).
  • §14.15 — Sender[T] is Clone, never Copy; the channel closes when the last sender drops; Sender[T]: Send requires T: Send.
  • §18.2 — print[T: Display](v: T); a mixed-arm match yields nothing joinable; fix-it is print(f"{x}").
  • CLAUDE.md/AGENTS.md — examples track the current spec; spec change updates the example in the same change; compiler/stdlib change that breaks one is a defect.
  • decisions.md D55 — all six with reasoning; Higher RAII named as a future ruling.

Docs-only: spec-inventory-check green. Implementation is non-compliant until the follow-ups land: facade void */drop (in progress), #1272 Sema rule (in progress), Sender Clone, print generic, examples update + CI lane (queued).

Eric Hartford and others added 2 commits September 22, 2026 08:32
…e's boundary (§2.5.1, §9.7), facade destroyers (§16.2b.3), Sender is Clone (§14.15), print over Display (§18.2); examples track the spec (D55)

Eric's rulings on the open questions from stage 4a, #1272 and the
examples survey (#1150), drafted as spec sentences for his blessing of the
words; decisions.md D55 records each ruling and its reasoning, including
Higher RAII for resources as a named future ruling. CLAUDE.md/AGENTS.md
carry the examples policy: a spec change that breaks an example updates
the example in the same change; a compiler or stdlib change that does is
a defect.
@ehartford
ehartford merged commit aad3210 into main Sep 22, 2026
3 of 5 checks passed
@ehartford
ehartford deleted the spec-rulings-drop-sender-print branch September 22, 2026 13:05
ehartford added a commit that referenced this pull request Sep 22, 2026
…e last sender's drop (D55 §14.15) (#1283)

* rt: with_channel_retain_sender — one more sender holds the channel open

Sender.clone() (D55 ruling 5, spec §14.15) needs the runtime refcount to go
up as well as down. The release path already closes the channel only when
the sender count reaches zero, so with a retain seam the channel closes on
the LAST sender's drop, never the first.

* std.channel: Sender[T] is Clone, never Copy; the channel closes on the last sender's drop

D55 ruling 5 / spec §14.15 (PR #1277): a shared producer is spelled
tx.clone(); every clone retains the runtime sender count and holds the
channel open; the channel closes when the last sender drops. Sender[T]: Send
iff T: Send was already the rule (SemaCheck type_generic_inst_satisfies_thread_trait)
and now has a test at the clone-into-fiber boundary.

Tests: close-on-last across three fiber producers (original + two clones);
a clone outliving the original keeps sends landing on the main thread;
Sender[Rc[i32]].clone() into a worker is rejected. Both behavior tests run
clean under --debug-alloc (leak count=0).

---------

Co-authored-by: Eric Hartford <[email protected]>
@ehartford

Copy link
Copy Markdown
Contributor Author

One-word correction proposed for the §18.2 bullet, from implementing ruling 6: print[T: Display](v: &T), not v: T. With v: T the generic consumes its argument: print(s); print(s) on an owned str becomes "use of moved value" and print(GLOBAL) becomes "cannot move out of global" (D52) — the standard test idiom breaks and every such call would need print(&s) ceremony, against §3.8 ("a function that observes takes &T"). With v: &T the substance of the ruling is unchanged — plain generic, the &str instance is today's print byte for byte, arms join under the Display bound, f-string fix-it — and auto-referencing keeps print(42), print("lit"), print(s), print(GLOBAL) free of &. Implementation proceeds with &T; the spec word is yours to bless (I have not changed the PR text).

ehartford added a commit that referenced this pull request Sep 22, 2026
…kes &T (§3.8); v: T consumed owned strings and refused globals (D52) (#1326)

Implementing D55 ruling 6 (PR #1325) showed the literal v: T consumes its
argument: print(s); print(s) on an owned str is a use-after-move and
print(GLOBAL) is a move out of a global. §3.8 says an observing function
takes &T; the &str instance is byte-identical to the previous print. One
word, proposed on #1277 and implemented in #1325; Eric's blessing is the
merge.

Co-authored-by: Eric Hartford <[email protected]>
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