Skip to content

Unelaborate deref temps in reverse postorder - #358

Open
coord-e wants to merge 1 commit into
mainfrom
claude/gifted-bohr-14ag86
Open

coord-e wants to merge 1 commit into
mainfrom
claude/gifted-bohr-14ag86

Conversation

@coord-e

@coord-e coord-e commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Fixes #357

unelaborate_derefs visited basic blocks in index order and recorded a deref temp's replacement only when it reached the statement that defines the temp. Drop elaboration can give a cleanup block that uses a box-deref temp a lower index than the cleanup block that defines it. This happens on the unwind path that drops a box's contents after *b is moved out. That use was left as it was while the definition became a Nop, so the temp's *const T was live all the way up to the function entry. refine_basic_blocks then panicked with unrefined_ty: *const T.

The fix visits blocks in reverse postorder. A temp's defining block dominates its uses, so in that order it is always visited first.

  • src/analyze/local_def.rs: iterate basic_blocks.reverse_postorder() in unelaborate_derefs.
  • tests/ui/{pass,fail}/box_move_out_after_call.rs: moving out of a Box<Box<i64>> after a Box::new call. On main this panics. With the fix it verifies, and a wrong assertion is Unsat.

The issue's other reproductions (list reversal cur = *rest, swap_head) also verify with this change, and a wrong assertion in each is still rejected. cargo test (402 UI tests, PCSat installed as in CI), cargo fmt --check and cargo clippy -D warnings all pass locally.


Generated by Claude Code

unelaborate_derefs visited blocks in index order, recording a
deref temp's replacement only when it reached the defining statement.
Drop elaboration can number a cleanup block that uses a box-deref temp
before the cleanup block that defines it (the unwind path dropping a
box's contents after `*b` is moved out). That use was left in place
while its definition became a Nop, so the temp's `*const T` type was
live up to the function entry and building block templates panicked
with `unrefined_ty: *const T`.

Visit blocks in reverse postorder, where a temp's defining block, which
dominates its uses, always comes first.

Fixes #357

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hw71PvwhBTUpfmvDdSGkXL
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T21:56:59.288420Z 9fca04d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants