Skip to content

Execute drop glue for Drop terminators#999

Draft
Stevengre wants to merge 3 commits intomasterfrom
codex/fix-interior-mut-drop-glue
Draft

Execute drop glue for Drop terminators#999
Stevengre wants to merge 3 commits intomasterfrom
codex/fix-interior-mut-drop-glue

Conversation

@Stevengre
Copy link
Contributor

Summary

interior-mut-fail.rs should pass under rustc, but KMIR failed on the second RefCell::borrow_mut() by reaching panic_already_borrowed(noBody).

The root cause was not RefCell writeback. It was that KMIR still treated MIR Drop terminators as no-ops, and the pre-proof SMIR reduction also discarded drop_in_place::<...> bodies because Drop was not modeled as a reachability edge.

This PR fixes that in two steps:

  • preserve reachable drop glue during SMIR reduction by adding Drop-based edges to call_edges
  • execute Drop terminators through the normal call path using reachable drop_in_place::<T> bodies

After that, the temporary RefMut guard from the first borrow_mut() is actually dropped, the borrow flag is released, and interior-mut passes.

Commit guide

  1. fix(kmir): execute drop glue for drop terminators
    This adds the semantic fix and renames interior-mut-fail.rs to interior-mut.rs, with an intermediate show output proving the case now reaches #EndProgram.
  2. test(kmir): drop redundant interior-mut show output
    This removes that temporary show output once it no longer carries diagnostic value.

Validation

  • make build
  • uv run pytest src/tests/integration/test_integration.py -v --timeout=600 -k 'interior-mut or interior-mut3-fail'
  • direct proofs:
    • interior-mut.main passes
    • interior-mut3-fail.main still fails with the existing misaligned-pointer issue

Notes

I also attempted a local make test-integration run after wiring deps/stable-mir-json into the worktree. It started cleanly, but I did not wait for the full suite to complete locally.

@Stevengre Stevengre changed the title Execute drop glue for terminators Execute drop glue for Drop terminators Mar 23, 2026
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.

1 participant