Skip to content

Commit 4d32b9a

Browse files
Hoist non-platform-specific code out of thread_local_inner!
1 parent a4e87e9 commit 4d32b9a

File tree

6 files changed

+10
-20
lines changed

6 files changed

+10
-20
lines changed

library/std/src/sys/thread_local/native/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ pub macro thread_local_inner {
108108
})
109109
}
110110
}},
111-
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $(#[$align_attr:meta])*, $($init:tt)*) => {
112-
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
113-
$crate::thread::local_impl::thread_local_inner!(@key $t, $(#[$align_attr])*, $($init)*);
114-
},
115111
}
116112

117113
#[rustc_macro_transparency = "semitransparent"]

library/std/src/sys/thread_local/no_threads.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ pub macro thread_local_inner {
3939
})
4040
}
4141
}},
42-
43-
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $(#[$align_attr:meta])*, $($init:tt)*) => {
44-
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
45-
$crate::thread::local_impl::thread_local_inner!(@key $t, $(#[$align_attr])*, $($init)*);
46-
},
4742
}
4843

4944
#[allow(missing_debug_implementations)]

library/std/src/sys/thread_local/os.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ pub macro thread_local_inner {
8585

8686
$($crate::thread::local_impl::thread_local_inner!(@align $final_align, $($attr_rest)+);)?
8787
},
88-
89-
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $(#[$($align_attr:tt)*])*, $($init:tt)*) => {
90-
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
91-
$crate::thread::local_impl::thread_local_inner!(@key $t, $(#[$($align_attr)*])*, $($init)*);
92-
},
9388
}
9489

9590
/// Use a regular global static to store this key; the state provided will then be

library/std/src/thread/local.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,17 @@ pub macro thread_local_process_attrs {
327327

328328
// process `const` declaration and recurse
329329
([$($align_attrs:tt)*] [$($other_attrs:tt)*]; $vis:vis static $name:ident: $t:ty = const $init:block $(; $($($rest:tt)+)?)?) => (
330-
$crate::thread::local_impl::thread_local_inner!($($other_attrs)* $vis $name, $t, $($align_attrs)*, const $init);
330+
$($other_attrs)* $vis const $name: $crate::thread::LocalKey<$t> =
331+
$crate::thread::local_impl::thread_local_inner!(@key $t, $($align_attrs)*, const $init);
332+
331333
$($($crate::thread::local_impl::thread_local_process_attrs!([] []; $($rest)+);)?)?
332334
),
333335

334336
// process non-`const` declaration and recurse
335337
([$($align_attrs:tt)*] [$($other_attrs:tt)*]; $vis:vis static $name:ident: $t:ty = $init:expr $(; $($($rest:tt)+)?)?) => (
336-
$crate::thread::local_impl::thread_local_inner!($($other_attrs)* $vis $name, $t, $($align_attrs)*, $init);
338+
$($other_attrs)* $vis const $name: $crate::thread::LocalKey<$t> =
339+
$crate::thread::local_impl::thread_local_inner!(@key $t, $($align_attrs)*, $init);
340+
337341
$($($crate::thread::local_impl::thread_local_process_attrs!([] []; $($rest)+);)?)?
338342
),
339343
}

tests/ui/macros/macro-local-data-key-priv.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: the constant `baz` is defined here
99
|
1010
LL | thread_local!(static baz: f64 = 0.0);
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= 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)
12+
= 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)
1313

1414
error: aborting due to 1 previous error
1515

tests/ui/thread-local/no-unstable.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | | }
1010
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
1111
= note: the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable
1212
= note: the `#[rustc_dummy]` attribute is used for rustc unit tests
13-
= 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)
13+
= 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)
1414

1515
error[E0658]: use of an internal attribute
1616
--> $DIR/no-unstable.rs:1:1
@@ -38,7 +38,7 @@ LL | | }
3838
= note: see issue #93798 <https://github.com/rust-lang/rust/issues/93798> for more information
3939
= help: add `#![feature(used_with_arg)]` to the crate attributes to enable
4040
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
41-
= 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)
41+
= 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)
4242

4343
error: `#[used]` attribute cannot be used on constants
4444
--> $DIR/no-unstable.rs:1:1
@@ -50,7 +50,7 @@ LL | | }
5050
| |_^
5151
|
5252
= help: `#[used]` can only be applied to statics
53-
= 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)
53+
= 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)
5454

5555
error: aborting due to 4 previous errors
5656

0 commit comments

Comments
 (0)