Use local_inner_macros to resolve all helper macros within $crate #165
No reviewers
Labels
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-bitflags/bitflags!165
Loading…
Reference in a new issue
No description provided.
Delete branch "local"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This fixes the following error when using Rust 2018 style macro imports.
The
local_inner_macrosmodifier resolves all macro invocations made from within that macro as helpers in the same crate. So ifbitflags!expands to an invocation of__bitflags!then this would be resolved as$crate::__bitflags!rather than requiring the caller to have__bitflagsin scope.The attribute is ignored by pre-2018 compilers so bitflags will continue to work as normal with #[macro_use].
In the future when dropping compatibility with pre-2018 compilers we can remove the
local_inner_macrosmodifier and use our own explicit$crate::prefixes on invocations of helper macros.Looks good to me! Thanks @dtolnay
Ah interesting... Is this a workaround to an inherent feature of
local_inner_macrosor just an implementation detail that might not be necessary in the future?This is what local_inner_macros means -- macro calls in the expansion are resolved as local helper macros. So a local_inner_macros macro cannot directly call a macro from a different crate, such as stringify from std.
bors: r+
Build succeeded