Skip to content

Analyze trait-bounded generic defs per instantiation; drop Fn closures called via FnOnce - #332

Open
coord-e wants to merge 2 commits into
mainfrom
claude/gifted-bohr-2ne9df
Open

coord-e wants to merge 2 commits into
mainfrom
claude/gifted-bohr-2ne9df

Conversation

@coord-e

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

Copy link
Copy Markdown
Owner

This PR fixes two independent bugs, one per commit.

Analyze defs with trait-bounded type params per instantiation (fixes #330, unsound)

A def whose signature does not mention its type parameters was registered as concrete. Its body was checked once, with every type parameter replaced by i32, and all instantiations reused that result. Two kinds of def are affected:

  • a static method of impl<T: K> W<T>
  • a self-less trait default method, where Self is the bounded parameter

The guard in placeholder_generic_args only looked at the def's own predicates, so bounds inherited from the parent impl or trait were missed.

The fix adds constrained_type_params, which collects bounds from predicates_of(..).instantiate_identity(tcx), so parent predicates are included. refine_fn_def now defers any def that has such a parameter, the same way it defers defs whose signature mentions a type parameter. placeholder_generic_args reuses the helper.

Drop an Fn closure called through FnOnce::call_once after the call (fixes #331, incompleteness)

RustCallVisitor case 2 replaces the moved closure with an immutable borrow, but moved_locals had already removed the closure's drop obligation. As a result, the &mut the closure captured was never resolved. The fix restores the obligation with drop_after_terminator, as case 3 already does.

Tests

  • Added pass/fail UI pairs generic_impl_static_method.rs and closure_fn_once_fn_kind.rs.
  • cargo test: all 398 UI tests pass, using the CI-pinned Z3 and PCSat.

🤖 Generated with Claude Code

https://claude.ai/code/session_013nBCcj2NXQuLQiJoxndHyP


Generated by Claude Code

claude added 2 commits October 9, 2026 22:09
A def whose signature does not mention its type parameters was checked
once with every type parameter replaced by i32, and that result was
reused for all instantiations. Bounds inherited from the parent impl or
trait (impl<T: K>, the trait's Self: K) escaped the guard in
placeholder_generic_args, which only looked at the def's own
predicates, so the body was verified against i32's impl.

Collect constrained type parameters including parent predicates, and
defer such defs so they are analyzed per instantiation.

Fixes #330

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nBCcj2NXQuLQiJoxndHyP
RustCallVisitor turns the moved closure into an immutable borrow, but
moved_locals had already removed its drop obligation, so the prophecies
of the mutable borrows it captured were never resolved. Restore the
obligation as the FnMut case already does.

Fixes #331

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

chatgpt-codex-connector Bot commented Oct 9, 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-09T22:13:21.039128Z 822e825 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