Skip to content

On a producer, a parent fixed to null is the absent parent: the constructor takes none and depends on nothing (D214, part of #3122) - #3588

Merged
ehartford merged 2 commits into
mainfrom
d214-absent-parent
Nov 24, 2026
Merged

ehartford merged 2 commits into
mainfrom
d214-absent-parent

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Part of #3122, which stays open for the second half of D214.

Ruled (D214): param N fixed null on the resource parameter of a producer says the parent is absent. The constructor takes no parent, lands on the produced type, and the value it returns depends on nothing.

Before: refused ("receives a modeled resource; a resource is passed by the value that owns it, never fixed"), and with rename new the producer collided with the parent's own new ("function 'Easy.new' is already defined").

Now:

resource Mime wraps *mut mime
    from mime_init
    drop mime_free
fn mime_init
    rename new
    param 0 fixed null    // a null parent makes an independent mime
…
fn solo() -> Mime: Mime.new().unwrap()    // returned freely: it borrows from nothing

How. One rule in four places that each decided "this parameter receives a resource" on their own: Sema's facade_param_receives, and the renderer's facade_render_receiver, facade_render_receives_any and facade_render_item_deps. A parameter the contract fixes is the facade's argument, received from nobody. The refusal stays for everything that is not a producer (err_c_facade_fixed_receiver still passes), and for a value other than null.

Not in this PR (still D214, recorded on the issue): two fn items for one C function, so the parented constructor can stand beside this one; the version floor on the claim; and the spec words for §16.2b.11, which go to Eric as a diff.

Test. behav_d214_producer_with_absent_parent (fails on main with the collision; leak count 0 under the debug allocator).

Evidence at 81c0481. The 36 tests that use fixed arguments or D214 pass; :native-compile-error-tests, :behavior-tests, :validate-all-tests, pre-checks green; battery green; linux-aarch64 container leg green (:build, :behavior-tests, :native-compile-error-tests); :release-checks survey: all targets green.

Eric Hartford added 2 commits November 24, 2026 04:55
…ructor takes none, lands on the produced type and depends on nothing (D214, part of #3122)
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