Repository navigation
fix(ts): emit a borrowed place's held temporaries before an edit reads it - #487
Merged
Merged
Conversation
Quest-Claim: dfa8e9cb30a2e271
…s it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 3, 2026 05:27
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
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.
Problem
A local
Stringthat some other path assigns whole is borrowed through anrt.Placetemporary.s.pop(),s.remove(0), ors.split_off(1)on it emitted a write through_N.vto a temporary that was never declared, sotscrefused the output. MIR reads the&mutonce, so the translator held itsrt.Placeback to fold into that one read. The edit then reads it twice: once inconst edit = rt.stringPop(_N.v), and again in the store_N.v = edit[0]. The first read folded the temporary away. Any other edit only got away with this when an operand between the borrow and the edit (such asoffset(&s, a)) flushed the temporary first.Approach
borrowed_placenow emits the held temporaries that its path reads, since every caller reads the place and then writes it. This replaces the per-callmaterializethatCow::to_mutandOption's inserts did by hand for the same reason.The
strsfixture drops #479's re-declaredlet s = s + ...workaround, so the local is now assigned whole. It also addsremove(0)andsplit_off(1)on the local: constant offsets that read nothing between the borrow and the edit. Without the fix,pop,remove(0), andsplit_off(1)failtsc. With it, they match native Rust in the differential test.Impact
pointers, one char argument is now its ownconstinstead of being folded into the+. That is cosmetic only.Alternatives
pop/remove/split_off. This was rejected because it is the same per-call pattern that let this bug in.&mut san alias ofseven whensis assigned twice (borrow checking keeps it put while borrowed). That would gives = ...output instead of anrt.Place. It is a wider change toalias/stableand was not needed for correctness.Follow-ups
None.
Review
Codex gpt-6.1-sol, medium, round 1 on
93d61273againstorigin/maine81934e2: 0 findings. Head37e23672adds only a conflict-free merge oforigin/main.🤖 Generated with Claude Code