Skip to content

Parse function typedef declarations at the function cursor - #3528

Draft
jadenfix wants to merge 1 commit into
rust-lang:mainfrom
jadenfix:fix/function-typedef-signatures
Draft

jadenfix wants to merge 1 commit into
rust-lang:mainfrom
jadenfix:fix/function-typedef-signatures

Conversation

@jadenfix

@jadenfix jadenfix commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Functions declared through a function typedef can panic during method code generation or static-wrapper serialization. Virtual methods can instead be emitted without their required this argument. For example, typedef int F(int); struct S { F take; }; panics, and virtual F take; produces an incorrect callable signature.

Resolve typedef/elaborated declaration types to their canonical function type before parsing the signature at the original function cursor. Ordinary function declarations keep their existing path. Added header coverage for instance/static/virtual/free functions, distinct receiver types and an alias chain, plus a C static-wrapper regression.

Fixes #3486.

Validation on main f08d4ff:

  • Both new regressions fail on unchanged main; the existing stdcall control passes.
  • Focused typedef suite: 27 passed.
  • Compiled generated bindings and executed six Rust-to-C++ calls, including two virtual receiver cases, plus one Rust-to-C call through a generated static wrapper. All passed on macOS arm64.
  • New expected bindings compile; the repository CI Clippy command, nightly formatting and diff checks pass.

Additional validation on the same PR commit:

  • All 24 integration tests pass.
  • Complete local header suite with libclang 17 and CLI round-trip duplication disabled: 641 passed, 1 failed (objc_template). A fresh isolated build of unchanged main fails that test with the identical generated-output diff. The earlier focused typedef checks included the normal round-trip checks.
  • All reported upstream CI checks are green on this commit, including Linux amd64/arm64, macOS, generated expectations and Clippy.

Ready for maintainer review. The native E2E evidence above is from macOS arm64; the upstream matrix supplies the additional platform validation.

Prepared with OpenAI Codex assistance; no independent human review is claimed.

@rustbot rustbot added the A-C++ label Oct 18, 2026

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++ method declared via a function typedef panics (How in the world?); virtual form drops this

2 participants