Skip to content

A pattern binding's view ends at its last use, as a let view's does (#3548); a store of the same field of another record fits the callback role (D213) - #3554

Merged
ehartford merged 2 commits into
mainfrom
callback-same-field
Nov 23, 2026
Merged

ehartford merged 2 commits into
mainfrom
callback-same-field

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Two changes.

#3548: a pattern binding's view ends at its last use. A view bound by let was already judged by its last use; a name bound from a place by a pattern was held to the end of its arm. So the rewrite the diagnostic suggests was itself refused inside an arm:

whole @ .Click(tag, n) =>
    let k = tag.name.len() as i32
    k + take(whole)          // was: 'whole' is moved while 'tag' still views it

A block retires the dead borrows of its own depth after each statement, and an arm's scope has no statements of its own. Its bindings live exactly as long as its body, so a block body is now given their borrows to retire: those the pattern made, and one the subject expression made (match &e:) that an arm binding names. A read after the move is still refused (err_pattern_view_read_after_move), and so is the read and the move in one expression: nothing there says the view's value is gone before the move.

The help now names the rewrite that works: "a view ends at its last use: read what you need from tag in a let on an earlier line, then move whole". D230's record is updated.

Tests: behav_pattern_view_ends_at_last_use (both forms; leak 0; passes every MIR validator), err_pattern_view_read_after_move.

D213: a same-field store. second->set.fdebug = data->set.fdebug (libcurl 8.23.0, http2.c): a store of the same field of another record of the same type fits field F of R is callback, per Eric's amendment of 2026-11-22. The scanner classifies it and it no longer leaves the field undecided. The spec's status note now names only the variadic store as not yet implemented. Test case in conan_facade_callback_field_test.

Closes #3548.

Battery green (540 s); :release-checks green.

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.

A pattern binding's view ends at its last use, as a let view's does: whole @ .Click(tag, n) => use(tag) + take(whole) is refused

1 participant