Skip to content

Commit 52fd64d

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

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
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
}

0 commit comments

Comments
 (0)