-
Notifications
You must be signed in to change notification settings - Fork 340
Cleanup: replace cfg-if with our macros #361
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
Conversation
@stjepang maybe prefixing the macro names with |
@yoshuawuyts Sounds good! I added the |
src/utils.rs
Outdated
@@ -20,6 +20,69 @@ pub fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T { | |||
t | |||
} | |||
|
|||
/// Declares unstable items. | |||
#[doc(hidden)] | |||
#[macro_export] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these macros exported?
I think it is enough to use #[macro_use]
for the utils
module if these macros are only used in this crate.
#[macro_use]
mod utils;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work - we have to keep #[macro_export]
or else the macro won't be visible from other modules. At least that's my understanding.
Do you know how to make this work without #[macro_export]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it work by doing the following. (see https://github.com/stjepang/async-std/pull/1)
- Apply
#[macro_use]
to the module where the macro is defined. - Remove
crate::
from all internal macro calls. - Remove
#[macro_export]
from the internal macro.
Remove #[macro_export] from internal macros
@taiki-e Thanks for removing |
This is a negative diff that only reshuffles code and cleans it up.
I added a few convenience macros that replace all uses of
cfg_if!
with new macrosunstable!
,unix!
,windows!
,docs!
, andnot_docs!
.