Hoist non-platform-specific code out of thread_local_inner!
This commit is contained in:
parent
a4e87e9406
commit
4d32b9a178
6 changed files with 10 additions and 20 deletions
|
|
@ -108,10 +108,6 @@ pub macro thread_local_inner {
|
|||
})
|
||||
}
|
||||
}},
|
||||
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $(#[$align_attr:meta])*, $($init:tt)*) => {
|
||||
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
|
||||
$crate::thread::local_impl::thread_local_inner!(@key $t, $(#[$align_attr])*, $($init)*);
|
||||
},
|
||||
}
|
||||
|
||||
#[rustc_macro_transparency = "semitransparent"]
|
||||
|
|
|
|||
|
|
@ -39,11 +39,6 @@ pub macro thread_local_inner {
|
|||
})
|
||||
}
|
||||
}},
|
||||
|
||||
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $(#[$align_attr:meta])*, $($init:tt)*) => {
|
||||
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
|
||||
$crate::thread::local_impl::thread_local_inner!(@key $t, $(#[$align_attr])*, $($init)*);
|
||||
},
|
||||
}
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
|
|
|
|||
|
|
@ -85,11 +85,6 @@ pub macro thread_local_inner {
|
|||
|
||||
$($crate::thread::local_impl::thread_local_inner!(@align $final_align, $($attr_rest)+);)?
|
||||
},
|
||||
|
||||
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $(#[$($align_attr:tt)*])*, $($init:tt)*) => {
|
||||
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
|
||||
$crate::thread::local_impl::thread_local_inner!(@key $t, $(#[$($align_attr)*])*, $($init)*);
|
||||
},
|
||||
}
|
||||
|
||||
/// Use a regular global static to store this key; the state provided will then be
|
||||
|
|
|
|||
|
|
@ -327,13 +327,17 @@ pub macro thread_local_process_attrs {
|
|||
|
||||
// process `const` declaration and recurse
|
||||
([$($align_attrs:tt)*] [$($other_attrs:tt)*]; $vis:vis static $name:ident: $t:ty = const $init:block $(; $($($rest:tt)+)?)?) => (
|
||||
$crate::thread::local_impl::thread_local_inner!($($other_attrs)* $vis $name, $t, $($align_attrs)*, const $init);
|
||||
$($other_attrs)* $vis const $name: $crate::thread::LocalKey<$t> =
|
||||
$crate::thread::local_impl::thread_local_inner!(@key $t, $($align_attrs)*, const $init);
|
||||
|
||||
$($($crate::thread::local_impl::thread_local_process_attrs!([] []; $($rest)+);)?)?
|
||||
),
|
||||
|
||||
// process non-`const` declaration and recurse
|
||||
([$($align_attrs:tt)*] [$($other_attrs:tt)*]; $vis:vis static $name:ident: $t:ty = $init:expr $(; $($($rest:tt)+)?)?) => (
|
||||
$crate::thread::local_impl::thread_local_inner!($($other_attrs)* $vis $name, $t, $($align_attrs)*, $init);
|
||||
$($other_attrs)* $vis const $name: $crate::thread::LocalKey<$t> =
|
||||
$crate::thread::local_impl::thread_local_inner!(@key $t, $($align_attrs)*, $init);
|
||||
|
||||
$($($crate::thread::local_impl::thread_local_process_attrs!([] []; $($rest)+);)?)?
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ note: the constant `baz` is defined here
|
|||
|
|
||||
LL | thread_local!(static baz: f64 = 0.0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ LL | | }
|
|||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
= note: the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable
|
||||
= note: the `#[rustc_dummy]` attribute is used for rustc unit tests
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0658]: use of an internal attribute
|
||||
--> $DIR/no-unstable.rs:1:1
|
||||
|
|
@ -38,7 +38,7 @@ LL | | }
|
|||
= note: see issue #93798 <https://github.com/rust-lang/rust/issues/93798> for more information
|
||||
= help: add `#![feature(used_with_arg)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: `#[used]` attribute cannot be used on constants
|
||||
--> $DIR/no-unstable.rs:1:1
|
||||
|
|
@ -50,7 +50,7 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
= help: `#[used]` can only be applied to statics
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_process_attrs` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue