File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 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 {
159159#[ allow_internal_unstable]
160160#[ allow_internal_unsafe]
161161macro_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]
164165 fn __init( ) -> $t { $init }
165166
166167 unsafe fn __getit( ) -> $crate:: option:: Option <
@@ -182,7 +183,16 @@ macro_rules! __thread_local_inner {
182183 unsafe {
183184 $crate:: thread:: LocalKey :: new( __getit, __init)
184185 }
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) ;
186196 }
187197}
188198
Original file line number Diff line number Diff line change @@ -16,5 +16,5 @@ mod bar {
1616
1717fn main ( ) {
1818 bar:: baz. with ( |_| ( ) ) ;
19- //~^ ERROR static `baz` is private
19+ //~^ ERROR `baz` is private
2020}
You can’t perform that action at this time.
0 commit comments