-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
2018: #[macro_export(local_inner_macros)] breaks recursion in submodules #52726
Comments
This is being fixed in #52234. |
resolve: Modularize crate-local `#[macro_export] macro_rules` Based on #50911, cc #50911 (comment) `#[macro_export] macro_rules` items are collected from the whole crate and are planted into the root module as items, so the external view of the crate is symmetric with its internal view and something like `$crate::my_macro` where `my_macro` is `#[macro_export] macro_rules` works both locally and from other crates. Closes #52726
I have a similar problem. In #[macro_export(local_inner_macros)]
macro_rules! select {
// ...
} Then, in another crate I invoke the macro like this: select! { default => {} } This works on stable Rust, but doesn't compile on nightly anymore:
It's complaining about this invocation of #[macro_export(local_inner_macros)]
macro_rules! select {
// ...
(@codegen_finalize
$token:ident
$index:ident
$selected:ident
$handles:ident
()
()
()
) => {
unreachable!("internal error in crossbeam-channel")
};
// ...
} If I change this to Is there anything I can do to make this compile on both stable and nightly? |
You can re-export unreachable like this: #[macro_export]
#[doc(hidden)]
macro_rules! crossbeam_unreachable {
($($args:tt)*) => {
unreachable! { $($args)* }
};
} |
Works perfectly, thank you! |
I tried adding
#[macro_export(local_inner_macros)]
to make a macro usable outside my crate, but it broke usability inside the crate (like for tests). The code:This works in 2015, and it works in 2018 if you remove
(local_inner_macros)
, but with both it doesn't. This seems like a problem for the migration path.The text was updated successfully, but these errors were encountered: