Conversation
An assignment through a reference (`*x = y`, `*slot = None`) is rewritten into a reborrow `m1 = &mut *x` followed by `^m1 = y`, and the old value `*m1` was discarded without being dropped. When it carries a `&mut`, that borrow's prophecy was never resolved, leaving the lender unconstrained after the borrow ends. A value behind a reference cannot have been moved out, so drop it at the assignment. Local-rooted places are left alone since their old value may already have been moved. Fixes #310 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KXQQHZrWQHhtpyTtWNgBP3
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. |
This branch has not been deployed
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.
Fixes #310.
An assignment through a reference (
*x = y,*slot = None) is rewritten byReborrowVisitorintom1 = &mut *x; *m1 = y, andassign_to_localonly assumes^m1 = y. The old value*m1was thrown away without being dropped. When it contains a&mut, that borrow's prophecy was never resolved, so the lender was havoc'd after the borrow ended.Change
ReborrowVisitor::visit_assign: if the assigned place goes through aDerefof a reference, drop*m1(the old value) once the rvalue's reborrows have been processed. A value behind a reference can't have been moved out. Local-rooted places (s.f = ..,*boxed = ..) are left alone because their old value may already have been moved, and resolving it again would be unsound.Env::drop_place/Analyzer::drop_place: these are the same dropping assumption asdrop_local, applied to a place.tests/ui/{pass,fail}/mut_ref_overwrite.rs: a callee writes through*xand then retargets it.passwasUnsatbefore this change.Testing
cargo test: 386 passed (Z3 5.0.0 + the pinned PCSat wrapper)cargo fmt --check,cargo clippy -- -D warnings: clean&mut-carrying value through a reference (*x = y,*slot = None) never resolves the overwritten borrow's prophecy, so the lender is havoc'd — even writes made before the overwrite are lost #310 now verify, and their flipped assertions are stillUnsat.🤖 Generated with Claude Code
https://claude.ai/code/session_01KXQQHZrWQHhtpyTtWNgBP3
Generated by Claude Code