Skip to content

Commit 7dd4c01

Browse files
authored
Merge pull request #81 from alekratz/master
Update to support Rust 1.18 visibility restrictions (see #80)
2 parents 4daab9f + afaf231 commit 7dd4c01

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/lib.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,23 @@ macro_rules! __lazy_static_internal {
119119
($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
120120
__lazy_static_internal!(@PRIV, $(#[$attr])* static ref $N : $T = $e; $($t)*);
121121
};
122+
($(#[$attr:meta])* pub(in $in:path) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
123+
__lazy_static_internal!(@PUB_IN, $in, $(#[$attr])* static ref $N : $T = $e; $($t)*);
124+
};
122125
($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
123126
__lazy_static_internal!(@PUB, $(#[$attr])* static ref $N : $T = $e; $($t)*);
124127
};
128+
(@PUB_IN, $in:path, $(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
129+
__lazy_static_internal!(@MAKE TY, PUB_IN, $in, $(#[$attr])*, $N);
130+
__lazy_static_internal!(@TAIL, $N : $T = $e);
131+
__lazy_static_internal!($($t)*);
132+
};
125133
(@$VIS:ident, $(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
126134
__lazy_static_internal!(@MAKE TY, $VIS, $(#[$attr])*, $N);
135+
__lazy_static_internal!(@TAIL, $N : $T = $e);
136+
__lazy_static_internal!($($t)*);
137+
};
138+
(@TAIL, $N:ident : $T:ty = $e:expr) => {
127139
impl $crate::__Deref for $N {
128140
type Target = $T;
129141
#[allow(unsafe_code)]
@@ -146,7 +158,6 @@ macro_rules! __lazy_static_internal {
146158
let _ = &**lazy;
147159
}
148160
}
149-
__lazy_static_internal!($($t)*);
150161
};
151162
(@MAKE TY, PUB, $(#[$attr:meta])*, $N:ident) => {
152163
#[allow(missing_copy_implementations)]
@@ -157,6 +168,15 @@ macro_rules! __lazy_static_internal {
157168
#[doc(hidden)]
158169
pub static $N: $N = $N {__private_field: ()};
159170
};
171+
(@MAKE TY, PUB_IN, $in:path, $(#[$attr:meta])*, $N:ident) => {
172+
#[allow(missing_copy_implementations)]
173+
#[allow(non_camel_case_types)]
174+
#[allow(dead_code)]
175+
$(#[$attr])*
176+
pub(in $in) struct $N {__private_field: ()}
177+
#[doc(hidden)]
178+
pub(in $in) static $N: $N = $N {__private_field: ()};
179+
};
160180
(@MAKE TY, PRIV, $(#[$attr:meta])*, $N:ident) => {
161181
#[allow(missing_copy_implementations)]
162182
#[allow(non_camel_case_types)]
@@ -175,6 +195,9 @@ macro_rules! lazy_static {
175195
($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
176196
__lazy_static_internal!(@PRIV, $(#[$attr])* static ref $N : $T = $e; $($t)*);
177197
};
198+
($(#[$attr:meta])* pub (in $in:path) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
199+
__lazy_static_internal!(@PUB_IN, $in, $(#[$attr])* static ref $N : $T = $e; $($t)*);
200+
};
178201
($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
179202
__lazy_static_internal!(@PUB, $(#[$attr])* static ref $N : $T = $e; $($t)*);
180203
};

0 commit comments

Comments
 (0)