Skip to content
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

Delete use of local_inner_macros #392

Merged
merged 3 commits into from Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/external.rs
Expand Up @@ -14,7 +14,7 @@ Next, re-export the library from the `__private` module here.
Next, define a macro like so:

```rust
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(feature = "serde")]
macro_rules! __impl_external_bitflags_my_library {
Expand All @@ -30,7 +30,7 @@ macro_rules! __impl_external_bitflags_my_library {
};
}

#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(not(feature = "my_library"))]
macro_rules! __impl_external_bitflags_my_library {
Expand Down Expand Up @@ -77,7 +77,7 @@ pub(crate) mod __private {
}

/// Implements traits from external libraries for the internal bitflags type.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_external_bitflags {
(
Expand All @@ -92,7 +92,7 @@ macro_rules! __impl_external_bitflags {
// Use `serde` as an example: generate code when the feature is available,
// and a no-op when it isn't

__impl_external_bitflags_serde! {
$crate::__impl_external_bitflags_serde! {
$InternalBitFlags: $T, $PublicBitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -101,7 +101,7 @@ macro_rules! __impl_external_bitflags {
}
}

__impl_external_bitflags_arbitrary! {
$crate::__impl_external_bitflags_arbitrary! {
$InternalBitFlags: $T, $PublicBitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -110,7 +110,7 @@ macro_rules! __impl_external_bitflags {
}
}

__impl_external_bitflags_bytemuck! {
$crate::__impl_external_bitflags_bytemuck! {
$InternalBitFlags: $T, $PublicBitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -125,7 +125,7 @@ macro_rules! __impl_external_bitflags {
pub mod serde;

/// Implement `Serialize` and `Deserialize` for the internal bitflags type.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(feature = "serde")]
macro_rules! __impl_external_bitflags_serde {
Expand Down Expand Up @@ -161,7 +161,7 @@ macro_rules! __impl_external_bitflags_serde {
};
}

#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(not(feature = "serde"))]
macro_rules! __impl_external_bitflags_serde {
Expand All @@ -182,7 +182,7 @@ pub mod arbitrary;
mod bytemuck;

/// Implement `Arbitrary` for the internal bitflags type.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(feature = "arbitrary")]
macro_rules! __impl_external_bitflags_arbitrary {
Expand All @@ -204,7 +204,7 @@ macro_rules! __impl_external_bitflags_arbitrary {
};
}

#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(not(feature = "arbitrary"))]
macro_rules! __impl_external_bitflags_arbitrary {
Expand All @@ -219,7 +219,7 @@ macro_rules! __impl_external_bitflags_arbitrary {
}

/// Implement `Pod` and `Zeroable` for the internal bitflags type.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(feature = "bytemuck")]
macro_rules! __impl_external_bitflags_bytemuck {
Expand Down Expand Up @@ -247,7 +247,7 @@ macro_rules! __impl_external_bitflags_bytemuck {
};
}

#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
#[cfg(not(feature = "bytemuck"))]
macro_rules! __impl_external_bitflags_bytemuck {
Expand Down
10 changes: 5 additions & 5 deletions src/internal.rs
Expand Up @@ -6,7 +6,7 @@
/// Declare the `bitflags`-facing bitflags struct.
///
/// This type is part of the `bitflags` crate's public API, but not part of the user's.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
macro_rules! __declare_internal_bitflags {
(
Expand All @@ -25,7 +25,7 @@ macro_rules! __declare_internal_bitflags {
///
/// Methods and trait implementations can be freely added here without breaking end-users.
/// If we want to expose new functionality to `#[derive]`, this is the place to do it.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_internal_bitflags {
(
Expand Down Expand Up @@ -97,7 +97,7 @@ macro_rules! __impl_internal_bitflags {

// The internal flags type offers a similar API to the public one

__impl_public_bitflags! {
$crate::__impl_public_bitflags! {
$InternalBitFlags: $T, $PublicBitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -106,11 +106,11 @@ macro_rules! __impl_internal_bitflags {
}
}

__impl_public_bitflags_ops! {
$crate::__impl_public_bitflags_ops! {
$InternalBitFlags
}

__impl_public_bitflags_iter! {
$crate::__impl_public_bitflags_iter! {
$InternalBitFlags: $T, $PublicBitFlags
}

Expand Down
42 changes: 21 additions & 21 deletions src/lib.rs
Expand Up @@ -442,7 +442,7 @@ bitflags! {
}
```
*/
#[macro_export(local_inner_macros)]
#[macro_export]
macro_rules! bitflags {
(
$(#[$outer:meta])*
Expand All @@ -457,13 +457,13 @@ macro_rules! bitflags {
) => {
// Declared in the scope of the `bitflags!` call
// This type appears in the end-user's API
__declare_public_bitflags! {
$crate::__declare_public_bitflags! {
$(#[$outer])*
$vis struct $BitFlags
}

// Workaround for: https://github.com/bitflags/bitflags/issues/320
__impl_public_bitflags_consts! {
$crate::__impl_public_bitflags_consts! {
$BitFlags: $T {
$(
$(#[$inner $($args)*])*
Expand All @@ -488,11 +488,11 @@ macro_rules! bitflags {
const _: () = {
// Declared in a "hidden" scope that can't be reached directly
// These types don't appear in the end-user's API
__declare_internal_bitflags! {
$crate::__declare_internal_bitflags! {
$vis struct InternalBitFlags: $T
}

__impl_internal_bitflags! {
$crate::__impl_internal_bitflags! {
InternalBitFlags: $T, $BitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -502,7 +502,7 @@ macro_rules! bitflags {
}

// This is where new library trait implementations can be added
__impl_external_bitflags! {
$crate::__impl_external_bitflags! {
InternalBitFlags: $T, $BitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -511,20 +511,20 @@ macro_rules! bitflags {
}
}

__impl_public_bitflags_forward! {
$crate::__impl_public_bitflags_forward! {
$BitFlags: $T, InternalBitFlags
}

__impl_public_bitflags_ops! {
$crate::__impl_public_bitflags_ops! {
$BitFlags
}

__impl_public_bitflags_iter! {
$crate::__impl_public_bitflags_iter! {
$BitFlags: $T, $BitFlags
}
};

bitflags! {
$crate::bitflags! {
$($t)*
}
};
Expand All @@ -538,7 +538,7 @@ macro_rules! bitflags {

$($t:tt)*
) => {
__impl_public_bitflags_consts! {
$crate::__impl_public_bitflags_consts! {
$BitFlags: $T {
$(
$(#[$inner $($args)*])*
Expand All @@ -559,7 +559,7 @@ macro_rules! bitflags {
clippy::iter_without_into_iter,
)]
const _: () = {
__impl_public_bitflags! {
$crate::__impl_public_bitflags! {
$BitFlags: $T, $BitFlags {
$(
$(#[$inner $($args)*])*
Expand All @@ -568,16 +568,16 @@ macro_rules! bitflags {
}
}

__impl_public_bitflags_ops! {
$crate::__impl_public_bitflags_ops! {
$BitFlags
}

__impl_public_bitflags_iter! {
$crate::__impl_public_bitflags_iter! {
$BitFlags: $T, $BitFlags
}
};

bitflags! {
$crate::bitflags! {
$($t)*
}
};
Expand All @@ -588,7 +588,7 @@ macro_rules! bitflags {
///
/// We need to be careful about adding new methods and trait implementations here because they
/// could conflict with items added by the end-user.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
macro_rules! __impl_bitflags {
(
Expand Down Expand Up @@ -797,7 +797,7 @@ macro_rules! __impl_bitflags {
///
/// If you find yourself with an attribute that should be considered expression-safe
/// and isn't, it can be added here.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
macro_rules! __bitflags_expr_safe_attrs {
// Entrypoint: Move all flags and all attributes into `unprocessed` lists
Expand All @@ -806,7 +806,7 @@ macro_rules! __bitflags_expr_safe_attrs {
$(#[$inner:ident $($args:tt)*])*
{ $e:expr }
) => {
__bitflags_expr_safe_attrs! {
$crate::__bitflags_expr_safe_attrs! {
expr: { $e },
attrs: {
// All attributes start here
Expand All @@ -831,7 +831,7 @@ macro_rules! __bitflags_expr_safe_attrs {
processed: [$($expr:tt)*],
},
) => {
__bitflags_expr_safe_attrs! {
$crate::__bitflags_expr_safe_attrs! {
expr: { $e },
attrs: {
unprocessed: [
Expand All @@ -858,7 +858,7 @@ macro_rules! __bitflags_expr_safe_attrs {
processed: [$($expr:tt)*],
},
) => {
__bitflags_expr_safe_attrs! {
$crate::__bitflags_expr_safe_attrs! {
expr: { $e },
attrs: {
unprocessed: [
Expand All @@ -885,7 +885,7 @@ macro_rules! __bitflags_expr_safe_attrs {
}

/// Implement a flag, which may be a wildcard `_`.
#[macro_export(local_inner_macros)]
#[macro_export]
#[doc(hidden)]
macro_rules! __bitflags_flag {
(
Expand Down