File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -159,8 +159,9 @@ macro_rules! thread_local {
159
159
#[ allow_internal_unstable]
160
160
#[ allow_internal_unsafe]
161
161
macro_rules! __thread_local_inner {
162
- ( $( #[ $attr: meta] ) * $vis: vis $name: ident, $t: ty, $init: expr) => {
163
- $( #[ $attr] ) * $vis static $name: $crate:: thread:: LocalKey <$t> = {
162
+ ( @key $( #[ $attr: meta] ) * $vis: vis $name: ident, $t: ty, $init: expr) => {
163
+ {
164
+ #[ inline]
164
165
fn __init( ) -> $t { $init }
165
166
166
167
unsafe fn __getit( ) -> $crate:: option:: Option <
@@ -182,7 +183,16 @@ macro_rules! __thread_local_inner {
182
183
unsafe {
183
184
$crate:: thread:: LocalKey :: new( __getit, __init)
184
185
}
185
- } ;
186
+ }
187
+ } ;
188
+ ( $( #[ $attr: meta] ) * $vis: vis $name: ident, $t: ty, $init: expr) => {
189
+ #[ cfg( stage0) ]
190
+ $( #[ $attr] ) * $vis static $name: $crate:: thread:: LocalKey <$t> =
191
+ __thread_local_inner!( @key $( #[ $attr] ) * $vis $name, $t, $init) ;
192
+
193
+ #[ cfg( not( stage0) ) ]
194
+ $( #[ $attr] ) * $vis const $name: $crate:: thread:: LocalKey <$t> =
195
+ __thread_local_inner!( @key $( #[ $attr] ) * $vis $name, $t, $init) ;
186
196
}
187
197
}
188
198
Original file line number Diff line number Diff line change @@ -16,5 +16,5 @@ mod bar {
16
16
17
17
fn main ( ) {
18
18
bar:: baz. with ( |_| ( ) ) ;
19
- //~^ ERROR static `baz` is private
19
+ //~^ ERROR `baz` is private
20
20
}
You can’t perform that action at this time.
0 commit comments