Repository navigation
D187 (#2965): returns borrow T from params N, M — a view of two origins - #3023
Merged
Merged
Conversation
A facade operation whose returned pointer is a part of either of two
parameters states both: the parser admits `from params <ref>, <ref>`
(a fifth clause operand); Sema binds `returns_borrow_from2` beside the
first origin (resolved and checked for its receipt the same way: a
resource, a record view or a C string), verifies it with the first once
every resource is known, and declares the rendered method's result a
view of both — the second as "through what the view views" (D85's
form), so a local view argument never pins the result to its binding;
a presented call's text borrows from both; the contract rows say "and
<param>, invalidated when either is". The migrator's proof unions two
borrow sources on different paths ("borrow:N,M": locals, returns and
callees through the argument map), carries `borrow_from2`, renders the
clause, and requires both origins modeled; a borrow of what the
function also frees or retains is reported raw, never as a borrow
(libxml2's xmlTextMerge), and the proof text no longer repeats an
origin per return.
Two defects met on the way, fixed at their lines:
- record_call_view_origins_args read "the shared dependency list did
not grow" as "this argument has no origin": two arguments viewing
one document pinned the result to the second argument's local.
- #3019: D144's "a binding of plain bits takes the value" copied a
facade record view out of its document; a record a facade hands out
as a view keeps the binding a view (type_carries_view).
The renderer presents a `*mut T` parameter whose pointee is a record
view as `&T`, passing the record's address, as a view's self crosses.
The ruling's first fixture, libxml2's xmlAddChild, is not a two-origin
borrow by the proof (it stores cur into the parent and frees it on the
text-merge path; its callee xmlInsertNode returns three sources): it
stays raw. Fixtures: behav_d187_borrow_from_two_params (a pick of two
nodes, `from a, b`, two nodes of one document), err_d187 (`from a`
alone refused), behav_3019. Conformance row D187 → implemented.
Contributor
Author
|
Gate green on 67a583e (422 s, seed-driven); |
ehartford
marked this pull request as ready for review
November 3, 2026 16:28
Contributor
Author
|
Battery green on 67a583e (seed-driven gate, uat, battery-checks; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2965. Closes #3019.
returns borrow T from params N, M(D187, §16.2b.6): a facade operation whose returned pointer is a part of either of two parameters states both, and the view is invalidated when either origin is.from params <ref>, <ref>(a fifth clause operand).returns_borrow_from2beside the first origin, resolved and checked for its receipt the same way (a resource, a record view, a C string) and verified with the first once every resource is known. The rendered method's result is declared a view of both: the second "through what the view views" (D85's form), so a local view argument never pins the result to its binding. A presented call's text borrows from both. Contract rows say "and<param>, invalidated when either is".*mut Tparameter whose pointee is a record view presents as&T, passing the record's address, as a view'sselfcrosses (Sema already counted it as receiving a record view; the renderer kept it raw).borrow_from2, renders the clause, requires both origins modeled; a borrow of what the function also frees or retains is reported raw ("… but it frees param N, which a borrowed return cannot state"), where main counted it as presented without presenting it; the proof text no longer repeats an origin per return.Two defects met on the way, fixed at their lines:
record_call_view_origins_argsread "the shared dependency list did not grow" as "this argument has no origin": two arguments viewing one document pinned the result to the second argument's local.type_carries_view).The ruling's first fixture, libxml2's
xmlAddChild, is not a two-origin borrow by the proof: it storescurinto the parent and frees it on the text-merge path, and its calleexmlInsertNodereturns three sources. Under D51 the migrator keeps it raw; its honest clause would be a consume of param 1 by param 0 plus a borrow from param 0. With the real libxml2 the drafted facade is byte-identical to main's (no function qualifies yet:xmlTextMergefrees one node, thexmlAutomataNew*borrows are of unmodeled records), and the UAT program builds against it. Surfacing this rather than editing the UAT.Fixtures:
behav_d187_borrow_from_two_params(a pick of two nodes;fn either(a, b) -> Option[&tnode] from a, b; two nodes of one document),err_d187_two_origin_view_outlives_one(from aalone refused: "returns a view derived fromb, which itsfromclause does not name"),behav_3019_record_view_of_plain_bits_stays_a_view. Conformance row D187 → implemented.Corners filed as issues at Eric's request: #3022 (origin list, not a second scalar), #3020 (record views: declare every origin "through",
selfincluded), #3021 (§14.10 example vsrecv: Option[T]).Iterate tier: the new fixtures failed on the installed compiler (parser refusal); on the stage1 they pass; 437 view/origin/facade behavior and compile-error fixtures pass; ceremony census diff ok. Gate,
:c-migrator-basic-tests --no-deps,:drop-auditreported below. Draft until the battery is green.