Skip to content

Don't use inner macro in marker_impls #111810

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

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,17 @@ use crate::hash::Hasher;
/// ```
#[unstable(feature = "internal_impls_macro", issue = "none")]
macro marker_impls {
( $(#[$($meta:tt)*])* $Trait:ident for $( $({$($bounds:tt)*})? $T:ty ),+ $(,)?) => {
// This inner macro is needed because... idk macros are weird.
// It allows repeating `meta` on all impls.
#[unstable(feature = "internal_impls_macro", issue = "none")]
macro _impl {
( $$({$$($$bounds_:tt)*})? $$T_:ty ) => {
$(#[$($meta)*])* impl<$$($$($$bounds_)*)?> $Trait for $$T_ {}
}
}
$( _impl! { $({$($bounds)*})? $T } )+
( $(#[$($meta:tt)*])* $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => {
$(#[$($meta)*])* impl< $($($bounds)*)? > $Trait for $T {}
marker_impls! { $(#[$($meta)*])* $Trait for $($($rest)*)? }
},
( $(#[$($meta:tt)*])* unsafe $Trait:ident for $( $({$($bounds:tt)*})? $T:ty ),+ $(,)?) => {
#[unstable(feature = "internal_impls_macro", issue = "none")]
macro _impl {
( $$({$$($$bounds_:tt)*})? $$T_:ty ) => {
$(#[$($meta)*])* unsafe impl<$$($$($$bounds_)*)?> $Trait for $$T_ {}
}
}
( $(#[$($meta:tt)*])* $Trait:ident for ) => {},

$( _impl! { $({$($bounds)*})? $T } )+
( $(#[$($meta:tt)*])* unsafe $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => {
$(#[$($meta)*])* unsafe impl< $($($bounds)*)? > $Trait for $T {}
marker_impls! { $(#[$($meta)*])* unsafe $Trait for $($($rest)*)? }
},
( $(#[$($meta:tt)*])* unsafe $Trait:ident for ) => {},
}

/// Types that can be transferred across thread boundaries.
Expand Down