Skip to content

Commit b0415db

Browse files
authored
Rollup merge of #111810 - compiler-errors:less-macro, r=thomcc
Don't use inner macro in `marker_impls` Just recurse instead of having to define an inner macro to avoid the problem with expansion binders being misnumbered between the `$meta` and `$T` variables. cc `@Veykril` this should fix rust-lang/rust-analyzer#14862 since we've gotten rid of the inner macro.
2 parents 3869b7b + e9a5a9d commit b0415db

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

library/core/src/marker.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,17 @@ use crate::hash::Hasher;
4343
/// ```
4444
#[unstable(feature = "internal_impls_macro", issue = "none")]
4545
macro marker_impls {
46-
( $(#[$($meta:tt)*])* $Trait:ident for $( $({$($bounds:tt)*})? $T:ty ),+ $(,)?) => {
47-
// This inner macro is needed because... idk macros are weird.
48-
// It allows repeating `meta` on all impls.
49-
#[unstable(feature = "internal_impls_macro", issue = "none")]
50-
macro _impl {
51-
( $$({$$($$bounds_:tt)*})? $$T_:ty ) => {
52-
$(#[$($meta)*])* impl<$$($$($$bounds_)*)?> $Trait for $$T_ {}
53-
}
54-
}
55-
$( _impl! { $({$($bounds)*})? $T } )+
46+
( $(#[$($meta:tt)*])* $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => {
47+
$(#[$($meta)*])* impl< $($($bounds)*)? > $Trait for $T {}
48+
marker_impls! { $(#[$($meta)*])* $Trait for $($($rest)*)? }
5649
},
57-
( $(#[$($meta:tt)*])* unsafe $Trait:ident for $( $({$($bounds:tt)*})? $T:ty ),+ $(,)?) => {
58-
#[unstable(feature = "internal_impls_macro", issue = "none")]
59-
macro _impl {
60-
( $$({$$($$bounds_:tt)*})? $$T_:ty ) => {
61-
$(#[$($meta)*])* unsafe impl<$$($$($$bounds_)*)?> $Trait for $$T_ {}
62-
}
63-
}
50+
( $(#[$($meta:tt)*])* $Trait:ident for ) => {},
6451

65-
$( _impl! { $({$($bounds)*})? $T } )+
52+
( $(#[$($meta:tt)*])* unsafe $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => {
53+
$(#[$($meta)*])* unsafe impl< $($($bounds)*)? > $Trait for $T {}
54+
marker_impls! { $(#[$($meta)*])* unsafe $Trait for $($($rest)*)? }
6655
},
56+
( $(#[$($meta:tt)*])* unsafe $Trait:ident for ) => {},
6757
}
6858

6959
/// Types that can be transferred across thread boundaries.

0 commit comments

Comments
 (0)