Skip to content

feat: add #[stageleft::export(Foo, Bar)] to pub-export macro-generated items#49

Merged
MingweiSamuel merged 6 commits into
mainfrom
export
Jan 16, 2026
Merged

feat: add #[stageleft::export(Foo, Bar)] to pub-export macro-generated items#49
MingweiSamuel merged 6 commits into
mainfrom
export

Conversation

@MingweiSamuel

Copy link
Copy Markdown
Member

No description provided.

@MingweiSamuel

MingweiSamuel commented Jan 15, 2026

Copy link
Copy Markdown
Member Author

I guess this macro can also apply to other items (not just macros) e.g. a struct macro that has some attributes which generate a newtype (like buildstructor perhaps), ill add those code paths too maybe

Edit: actually I will punt this to later. see branch #50 https://github.com/hydro-project/stageleft/tree/stageleft-export-macro-2

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new #[stageleft::export(...)] attribute macro that allows marking macro invocations that generate one or more pub items. This prevents "splitbrain" issues where macro-generated types are re-invoked in staged code, causing type mismatches between the original and staged versions.

Changes:

  • Adds #[stageleft::export(...)] attribute macro to mark macro invocations that generate public items
  • Implements build-time code generation to replace marked macros with re-exports in staged code
  • Adds a new test package stageleft_test_no_entry to verify the functionality
  • Includes compile-fail test to ensure exported items must be public

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
stageleft_macro/src/lib.rs Implements the new export attribute macro that validates and marks macro-generated items
stageleft_tool/src/lib.rs Adds logic to detect stageleft::export attributes and replace marked macros with re-exports in staged code
stageleft/src/lib.rs Exports the new export macro to make it publicly available
stageleft_test_no_entry/* New test package demonstrating the export feature with slotmap's new_key_type! macro
stageleft/tests/compile-fail/* Compile-fail test ensuring exported items must be pub
Cargo.toml, Cargo.lock, stageleft/Cargo.toml Adds new test package and slotmap dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread stageleft_tool/src/lib.rs Outdated
Comment thread stageleft_macro/src/lib.rs Outdated
Comment thread stageleft_test_no_entry/src/lib.rs Outdated
MingweiSamuel and others added 4 commits January 15, 2026 12:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread stageleft_macro/src/lib.rs
@MingweiSamuel
MingweiSamuel merged commit 2714993 into main Jan 16, 2026
4 checks passed
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.

3 participants