This seems an old topic but I lose track of its most recent progress. Simply speaking I'd to define macros in a module (not necessarily root module) inside a crate and use it from another crate. Currently the only way to do this seems #[macro_export] which exports the macro at crate root, not the module where it is defined.
By the way I've seen several hacks using #[macro_export] with hashed macro identifiers but none of them can avoid the crate root namespace pollution. They make it hard, but not impossible, to access the hashed identifiers.
How does this allow you to use the macro from a different crate? You can't pub use a non-macro_export macro. You can pub(crate) use or pub(super) use it, but these don't export the macro to a different crate?
Ultimately there must be something exported at the crate root unless you define the macro in a separate crate and re-export it. You can make it difficult to use and hide it from documentation at the crate root, however.
The only positive way to avoid this is to involve a new external crate, kind of like we already need for proc-macros, only for #[macro_export]ed macro_rules! macros, this time.
Basically in that thread you linked to, my post over
does "summarize" the latest situation w.r.t. these things
After reading several posts it's still unclear to me why #[macro_export] must export at crate root. I think most people would like the export at macro definition module.
In addition, in that post you suggested pub macro_rules! and:
the compiler machinery for all this is already available, it's just a matter of switching the knob to enable it;
And I'm wondering why this is still not doable with the latest rust compiler. Ideally we don't need #[macro_export] but control macro visibility solely with pub, pub(crate), etc.