Repository navigation
Accept writes and borrows through temporary-pointer places - #1634
Merged
Merged
Conversation
The frontend treated a location as assignable or borrowable only when it had a binding-rooted place or was a bare pointer dereference. So `*f() = v` and `ref *f()` were accepted, but `f().field = v`, `(*f()).field += 1` and `mut f().field` were rejected, although lowering already supports these places. Recognize memory addressed through a pointer, including fields and array elements projected from it, as a place for assignment, compound assignment, explicit borrows and call-argument borrows. Such borrows use the Memory provider, as a bare dereference already did. Projections of rvalues that are not pointers remain rejected.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Base automatically changed from
fix/call-result-raw-ptr-projection
to
master
September 29, 2026 19:54
cburgdorf
added a commit
that referenced
this pull request
Sep 29, 2026
The lowering and type checking for places reached through a temporary pointer landed on master (#1633, #1634). Keep this branch's extra coverage on top of it: - `temporary_pointer_field.fe` exercises reads, writes, compound assignment and explicit `mut`/`ref` borrows of fields reached through pointer-returning calls such as `orders.ptr_at(0).n`, including chained `ptr_at` calls and pointer fields of temporaries. - `borrow_custom_index_through_pointer.fe` pins that a built-in array element below a temporary pointer is borrowable, while a custom `Index` call below one is still rejected as a non-place.
sbillig
pushed a commit
that referenced
this pull request
Sep 30, 2026
The lowering and type checking for places reached through a temporary pointer landed on master (#1633, #1634). Keep this branch's extra coverage on top of it: - `temporary_pointer_field.fe` exercises reads, writes, compound assignment and explicit `mut`/`ref` borrows of fields reached through pointer-returning calls such as `orders.ptr_at(0).n`, including chained `ptr_at` calls and pointer fields of temporaries. - `borrow_custom_index_through_pointer.fe` pins that a built-in array element below a temporary pointer is borrowable, while a custom `Index` call below one is still rejected as a non-place.
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.
Stacked on #1633.
*f() = vandref *f()were accepted. Assigning or borrowing a field or element reached through a temporary pointer was rejected:f().value = 5,(*f()).items[i] += 1,mut f().inner. Semantic lowering already supports these places. Only the frontend admission checks insisted on a binding-rooted place or a bare dereference.A shared
is_pointer_place_exprnow recognizes memory addressed through a pointer:*eThe following use it, replacing their bare-dereference special cases:
ref/mutborrowsThese borrows use the Memory provider, as
ref *f()already did. Projections of non-pointer rvalues, such asmake().value = 1, remain rejected.