Skip to content

Conversation

@sumleo
Copy link

@sumleo sumleo commented Feb 12, 2026

Summary

  • When collect_equal_types unions structurally identical types from different interfaces, the TypeInfo (borrowed/owned/error flags) was not being merged
  • This caused incorrect code generation when a type appeared as an import parameter in one interface and an export return in another — only one side's flags would be visible, leading to missing borrowed or owned type variants
  • Added a post-pass in collect_equal_types that merges TypeInfo across all members of each equivalence class using the existing BitOrAssign implementation

Test plan

  • Added codegen test in crates/rust/tests/codegen.rs with two interfaces containing structurally equal payload records (one imported, one exported) using merge_structurally_equal_types and Borrowing ownership
  • Verified the test compiles and generates code without panic
  • All existing workspace tests pass

When `collect_equal_types` unions structurally identical types from
different interfaces, the TypeInfo (borrowed/owned/error flags) was not
being merged. This caused incorrect code generation when a type was
imported in one interface and exported in another - only one side's
flags would be visible, leading to missing borrowed or owned type
variants.

Add a post-pass in `collect_equal_types` that merges TypeInfo across
all members of each equivalence class, so the representative carries
the union of all usage flags.
@sumleo sumleo force-pushed the fix/merge-typeinfo-equal-types branch from a327640 to 992bc51 Compare February 12, 2026 13:41
@alexcrichton
Copy link
Member

Thanks! Could the test be modeled as a new file in tests/codegen/*.wit? It could then be modeled here with a new variant that passes --merge-structurally-equal-types

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.

2 participants