Skip to content

Commit 8cce5bc

Browse files
committed
use :vis in thread_local!
1 parent b6a2d7e commit 8cce5bc

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
#![feature(link_args)]
278278
#![feature(linkage)]
279279
#![feature(macro_reexport)]
280+
#![feature(macro_vis_matcher)]
280281
#![feature(needs_panic_runtime)]
281282
#![feature(needs_drop)]
282283
#![feature(never_type)]

src/libstd/thread/local.rs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -139,37 +139,15 @@ macro_rules! thread_local {
139139
// empty (base case for the recursion)
140140
() => {};
141141

142-
// process multiple declarations where the first one is private
143-
($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
144-
__thread_local_inner!($(#[$attr])* [] $name, $t, $init);
142+
// process multiple declarations
143+
($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
144+
__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
145145
thread_local!($($rest)*);
146146
);
147147

148-
// handle a single private declaration
149-
($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr) => (
150-
__thread_local_inner!($(#[$attr])* [] $name, $t, $init);
151-
);
152-
153-
// handle multiple declarations where the first one is public
154-
($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
155-
__thread_local_inner!($(#[$attr])* [pub] $name, $t, $init);
156-
thread_local!($($rest)*);
157-
);
158-
159-
// handle a single public declaration
160-
($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr) => (
161-
__thread_local_inner!($(#[$attr])* [pub] $name, $t, $init);
162-
);
163-
164-
// handle multiple declarations where the first one is restricted public
165-
($(#[$attr:meta])* pub $vis:tt static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
166-
__thread_local_inner!($(#[$attr])* [pub $vis] $name, $t, $init);
167-
thread_local!($($rest)*);
168-
);
169-
170-
// handle a single restricted public declaration
171-
($(#[$attr:meta])* pub $vis:tt static $name:ident: $t:ty = $init:expr) => (
172-
__thread_local_inner!($(#[$attr])* [pub $vis] $name, $t, $init);
148+
// handle a single declaration
149+
($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => (
150+
__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
173151
);
174152
}
175153

@@ -180,8 +158,8 @@ macro_rules! thread_local {
180158
#[macro_export]
181159
#[allow_internal_unstable]
182160
macro_rules! __thread_local_inner {
183-
($(#[$attr:meta])* [$($vis:tt)*] $name:ident, $t:ty, $init:expr) => {
184-
$(#[$attr])* $($vis)* static $name: $crate::thread::LocalKey<$t> = {
161+
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => {
162+
$(#[$attr])* $vis static $name: $crate::thread::LocalKey<$t> = {
185163
fn __init() -> $t { $init }
186164

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

0 commit comments

Comments
 (0)