Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow proc-macro crates to export macro_rules macros #40090
Comments
This comment has been minimized.
This comment has been minimized.
|
Do plugin crates allow exporting macros? The implementation is similar. |
jseyfried
self-assigned this
Feb 25, 2017
This comment has been minimized.
This comment has been minimized.
|
cc @nrc |
This comment has been minimized.
This comment has been minimized.
|
I’ve realized that I can do this the other way around, which is even better: re-export procedural macros from a library crate: // In cssparser’s lib.rs
#[macro_use] extern crate cssparser_macros;
pub use cssparser_macros::*;Crates using this library only need one // Import both cssparser_macros::* and macro_rules! macro exported by cssparser itself.
#[macro_use] extern crate cssparser;Although it would be nice for this issue to be fixed eventually, for me the above removes any desire to see it prioritized. |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure this is a good idea in the first place -- since we don't allow exporting an item (e.g. Eventually, we might allow exporting arbitrary items, but we'll probably need a story for phases first (quite a ways down the road). |
SimonSapin commentedFeb 25, 2017
In rustc 1.17.0-nightly (413a975 2017-02-23), this
causes a compiler error:
As far as I understand, proc-macro crates can currently only export procedural macros because when cross-compiling they’re compiler for the host whereas "normal" crates are compiler for the target, and items such as functions or types defined in a proc-macro crate would also need to be compiler for the target when used (through a dependency) on a "normal" crate. But this is not a problem for
macro_ruleswhich is purely compile-time.So it seems that lifting this restriction for
macro_rulesmight require less implementation effort than lifting it for every kind of item?