mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Hoist non-platform-specific code out of thread_local_inner!
This commit is contained in:
@@ -108,10 +108,6 @@ fn __init() -> $t {
|
||||
})
|
||||
}
|
||||
}},
|
||||
($(#[$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 @@ fn __init() -> $t { $init }
|
||||
})
|
||||
}
|
||||
}},
|
||||
|
||||
($(#[$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 @@ fn __init() -> $t { $init }
|
||||
|
||||
$($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 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user