Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export core symbols from derive_utils module. #277

Closed
joshlf opened this issue Aug 21, 2023 · 1 comment
Closed

Re-export core symbols from derive_utils module. #277

joshlf opened this issue Aug 21, 2023 · 1 comment
Labels
compatibility-nonbreaking Changes that are (likely to be) non-breaking

Comments

@joshlf
Copy link
Member

joshlf commented Aug 21, 2023

Currently, some generated code (generated by zerocopy-derive and generated when invoking zerocopy macros like transmute! or those in derive_utils) relies directly on ::core, which can be problematic in a context in which core has not been explicitly included (in older versions of Rust, with the exception of no_std crates, core was not included in the root namespace by default) or in which it has been renamed. Note that some code avoids this problem (e.g., for transmute!, we have a top level pub use core::mem::transmute as __real_transmute).

It might be better if we had a uniform solution to this problem. One option would be to re-export all of core, and then change macros and zerocopy-derive to emit code which uses zerocopy::core_reexport::.... An open question is where this reexport should live and what it should be named. A natural location might be derive_utils, but that doesn't really make sense for macros that are not related to zerocopy-derive (like transmute!). We could also consider moving things around so that there's a parent module over all exported macros (ie, not including internal-only macros like safety_comment!), which would provide a natural location for the re-export.

See also #11, which tracks macro hygiene.

@joshlf joshlf added the compatibility-nonbreaking Changes that are (likely to be) non-breaking label Aug 21, 2023
@joshlf
Copy link
Member Author

joshlf commented Aug 21, 2023

cc @Kestrer, who expressed interest in macro hygiene. Let me know if you have feedback on this proposal!

@joshlf joshlf closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-nonbreaking Changes that are (likely to be) non-breaking
Projects
None yet
Development

No branches or pull requests

1 participant