File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,12 @@ use std::cell::Cell;
5151use std:: marker;
5252use std:: thread:: LocalKey ;
5353
54+ /// The macro. See the module level documentation for the description and examples.
5455#[ macro_export]
5556#[ cfg( not( feature = "nightly" ) ) ]
5657macro_rules! scoped_thread_local {
57- ( static $name: ident: $ty: ty) => (
58+ ( $( #[ $attrs: meta] ) * static $name: ident: $ty: ty) => (
59+ $( #[ $attrs] ) *
5860 static $name: $crate:: ScopedKey <$ty> = $crate:: ScopedKey {
5961 inner: {
6062 thread_local!( static FOO : :: std:: cell:: Cell <usize > = {
@@ -67,11 +69,13 @@ macro_rules! scoped_thread_local {
6769 )
6870}
6971
72+ /// The macro. See the module level documentation for the description and examples.
7073#[ macro_export]
7174#[ allow_internal_unstable]
7275#[ cfg( feature = "nightly" ) ]
7376macro_rules! scoped_thread_local {
74- ( $vis: vis static $name: ident: $ty: ty) => (
77+ ( $( #[ $attrs: meta] ) * $vis: vis static $name: ident: $ty: ty) => (
78+ $( #[ $attrs] ) *
7579 $vis static $name: $crate:: ScopedKey <$ty> = $crate:: ScopedKey {
7680 inner: {
7781 thread_local!( static FOO : :: std:: cell:: Cell <usize > = {
@@ -266,4 +270,20 @@ mod tests {
266270 assert_eq ! ( rx. recv( ) . unwrap( ) , 1 ) ;
267271 assert ! ( t. join( ) . is_err( ) ) ;
268272 }
273+
274+ #[ test]
275+ fn attrs_allowed ( ) {
276+ scoped_thread_local ! (
277+ /// Docs
278+ static BAZ : u32
279+ ) ;
280+
281+ scoped_thread_local ! (
282+ #[ allow( non_upper_case_globals) ]
283+ static quux: u32
284+ ) ;
285+
286+ let _ = BAZ ;
287+ let _ = quux;
288+ }
269289}
You can’t perform that action at this time.
0 commit comments