Skip to content

Commit 5fde1e2

Browse files
committed
use :vis in thread_local!
1 parent 7b349d2 commit 5fde1e2

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
#![feature(link_args)]
283283
#![feature(linkage)]
284284
#![feature(macro_reexport)]
285+
#![feature(macro_vis_matcher)]
285286
#![feature(needs_panic_runtime)]
286287
#![feature(never_type)]
287288
#![feature(num_bits_bytes)]

src/libstd/thread/local.rs

+8-30
Original file line numberDiff line numberDiff line change
@@ -133,37 +133,15 @@ macro_rules! thread_local {
133133
// empty (base case for the recursion)
134134
() => {};
135135

136-
// process multiple declarations where the first one is private
137-
($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
138-
__thread_local_inner!($(#[$attr])* [] $name, $t, $init);
136+
// process multiple declarations
137+
($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
138+
__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
139139
thread_local!($($rest)*);
140140
);
141141

142-
// handle a single private declaration
143-
($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr) => (
144-
__thread_local_inner!($(#[$attr])* [] $name, $t, $init);
145-
);
146-
147-
// handle multiple declarations where the first one is public
148-
($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
149-
__thread_local_inner!($(#[$attr])* [pub] $name, $t, $init);
150-
thread_local!($($rest)*);
151-
);
152-
153-
// handle a single public declaration
154-
($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr) => (
155-
__thread_local_inner!($(#[$attr])* [pub] $name, $t, $init);
156-
);
157-
158-
// handle multiple declarations where the first one is restricted public
159-
($(#[$attr:meta])* pub $vis:tt static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
160-
__thread_local_inner!($(#[$attr])* [pub $vis] $name, $t, $init);
161-
thread_local!($($rest)*);
162-
);
163-
164-
// handle a single restricted public declaration
165-
($(#[$attr:meta])* pub $vis:tt static $name:ident: $t:ty = $init:expr) => (
166-
__thread_local_inner!($(#[$attr])* [pub $vis] $name, $t, $init);
142+
// handle a single declaration
143+
($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => (
144+
__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
167145
);
168146
}
169147

@@ -174,8 +152,8 @@ macro_rules! thread_local {
174152
#[macro_export]
175153
#[allow_internal_unstable]
176154
macro_rules! __thread_local_inner {
177-
($(#[$attr:meta])* [$($vis:tt)*] $name:ident, $t:ty, $init:expr) => {
178-
$(#[$attr])* $($vis)* static $name: $crate::thread::LocalKey<$t> = {
155+
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => {
156+
$(#[$attr])* $vis static $name: $crate::thread::LocalKey<$t> = {
179157
fn __init() -> $t { $init }
180158

181159
fn __getit() -> $crate::option::Option<

0 commit comments

Comments
 (0)