Skip to content

refactor: Fix callback merging and moved type paths - #2038

Open
thedataking wants to merge 2 commits into
masterfrom
issue-2037
Open

thedataking wants to merge 2 commits into
masterfrom
issue-2037

Conversation

@thedataking

Copy link
Copy Markdown
Contributor

reorganize_definitions splits equivalent SQLite extension API tables because callbacks combining translation-unit-local types with VaList have bound lifetimes. Compare those function-pointer signatures modulo bound-variable names while preserving lifetime relationships, generic arguments, safety, ABI, representation, bitfield metadata, and array lengths.

Moved header declarations can also lose the imports that named source-local types. Qualify those references from their original resolved definitions before moving the declarations, preserving generic arguments.

Together these changes let SQLite's CLI shell and bundled extensions share their API table and keep moved declarations well-typed.

Fixes #2037.

@thedataking
thedataking requested a review from ahomescu October 15, 2026 13:19
@thedataking
thedataking marked this pull request as ready for review October 17, 2026 02:04
@ahomescu

Copy link
Copy Markdown
Contributor

As a general comment, this could have been 3 or 4 PRs in a stack.

Comment thread c2rust-refactor/src/context.rs Resolved
Comment thread c2rust-refactor/src/transform/vars.rs Resolved
SQLite extension API tables combine translation-unit-local types with bound VaList lifetimes. Compare these callbacks modulo binder names while retaining layout, bitfield, generic argument, and signature distinctions so equivalent tables can share one definition safely.

Qualify references to unmoved source-local items before moving header declarations, since their imports may remain with inline functions or be subsumed by other declarations.
Strict structural array comparison protects ADT layouts, but incomplete C extern arrays still need to match complete definitions. Avoid generating an invalid whole-array cast for this case without weakening comparisons of struct fields or array elements. When canonicalize_externs replaces a complete extern array with an incomplete one, access it through a pointer to the complete array type so indexing and length are preserved.
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.

reorganize_definitions breaks SQLite when the CLI shell and its extensions are included

2 participants