My understanding is that macro_rules
macros can't be imported with use
, because there are some unresolved questions about macro-expansion ordering. However, I've now discovered that one can in fact use this macro, via reexport and new-style lexically scoped use
. Is this a feature, or a bug?
mod macros { macro_rules! _my_macro { () => () } pub(crate) use _my_macro as my_macro; } mod b { crate::macros::my_macro!(); super::macros::my_macro!(); // my_macro!(); }
cc @Vadim Petrochenkov
This is a direct consequence of "uniform paths", if the macro can be called, then it can be used as well.
Not sure what are the unresolved questions here.
So, use
ing macro_rules
macros (without this hack) is not allowed simply because it's not implemented, and not because there's some big reason not to allow it?
They can't be used because they have strange scoping, not because there's a special rule for use
and macros.
macro_rules! m { () => {}} mod x { use m as k; // OK on 2018 - This isn't allowed on 2015 because `::m!()` isn't either. k!(); }