Skip to content

fix renamed enum and struct re-exports in rust codegen#11228

Open
amirHdev wants to merge 2 commits intoslint-ui:masterfrom
amirHdev:compiler-preserve-export-identities
Open

fix renamed enum and struct re-exports in rust codegen#11228
amirHdev wants to merge 2 commits intoslint-ui:masterfrom
amirHdev:compiler-preserve-export-identities

Conversation

@amirHdev
Copy link
Copy Markdown
Contributor

@amirHdev amirHdev commented Apr 1, 2026

Summary

Fix a compiler issue where renamed exported enums and structs could lose their public identity during
import or re-export resolution.

Fixes #9094

Update

The major problem was that renamed public identities are needed for Rust codegen but plain alias imports must still remain semantically.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5b320d65d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@amirHdev amirHdev force-pushed the compiler-preserve-export-identities branch from 5f18a0d to 06684d7 Compare April 2, 2026 00:13
@ogoffart
Copy link
Copy Markdown
Member

ogoffart commented Apr 2, 2026

Thanks for tackling this issue.
Could you also make a test in tests/cases/export
(you can maybe extend tests/cases/export/named_export by re-declaring structs of the same name in the rust and cpp part)

The other problem is that this is a breaking change and i don't know if this is acceptable.
Perhaps an alternative would be to keep the export as deprecated, as i write in #9094 (comment)
(this can be tested with the #[expect(deprecated)] when using it in a rust block in tests/cases

@amirHdev
Copy link
Copy Markdown
Contributor Author

amirHdev commented Apr 2, 2026

The other problem is that this is a breaking change and i don't know if this is acceptable. Perhaps an alternative would be to keep the export as deprecated, as i write in #9094 (comment) (this can be tested with the #[expect(deprecated)] when using it in a rust block in tests/cases

To make that design correct we’d need to decide whether the old name should stop being a normal public export in those cases which is a larger API shape.

- preserve renamed public identities for re-exports and direct imports without local aliases
- keep alias imports semantically tied to the original type
- allow same-origin renamed enums in strict two-way binding checks
- cover the Rust codegen regression from issue 9094

Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@amirHdev amirHdev force-pushed the compiler-preserve-export-identities branch 3 times, most recently from 8bc1bb8 to 10ba915 Compare April 2, 2026 16:53
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@amirHdev amirHdev force-pushed the compiler-preserve-export-identities branch from 10ba915 to 8947276 Compare April 2, 2026 17:10
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.

Enums and Structs are exported using original name as well as the renamed one

2 participants