@@ -43,15 +43,15 @@ mod extern_class;
4343#[ macro_export]
4444macro_rules! class {
4545 ( $name: ident) => { {
46- $crate:: __class_inner!( $name)
46+ $crate:: __class_inner!( $name, $crate :: __hash_idents! ( $name ) )
4747 } } ;
4848}
4949
5050#[ doc( hidden) ]
5151#[ macro_export]
5252#[ cfg( not( feature = "unstable-static-class" ) ) ]
5353macro_rules! __class_inner {
54- ( $name: ident) => { {
54+ ( $name: ident, $_hash : expr ) => { {
5555 use $crate:: __macro_helpers:: { concat, panic, stringify, CachedClass , None , Some } ;
5656 static CACHED_CLASS : CachedClass = CachedClass :: new( ) ;
5757 let name = concat!( stringify!( $name) , '\0' ) ;
@@ -191,15 +191,15 @@ macro_rules! sel {
191191 ( $first: ident $( : $( $rest: ident : ) * ) ?) => ( {
192192 use $crate:: __macro_helpers:: { concat, stringify, str } ;
193193 const SELECTOR_DATA : & str = concat!( stringify!( $first) , $( ':' , $( stringify!( $rest) , ':' , ) * ) ? '\0' ) ;
194- $crate:: __sel_inner!( SELECTOR_DATA , $first $( $( $rest) * ) ?)
194+ $crate:: __sel_inner!( SELECTOR_DATA , $crate :: __hash_idents! ( $ first $( $( $rest) * ) ?) )
195195 } ) ;
196196}
197197
198198#[ doc( hidden) ]
199199#[ macro_export]
200200#[ cfg( not( feature = "unstable-static-sel" ) ) ]
201201macro_rules! __sel_inner {
202- ( $data: expr, $( $idents : ident ) + ) => { {
202+ ( $data: expr, $_hash : expr ) => { {
203203 use $crate:: __macro_helpers:: CachedSel ;
204204 static CACHED_SEL : CachedSel = CachedSel :: new( ) ;
205205 #[ allow( unused_unsafe) ]
@@ -229,7 +229,7 @@ macro_rules! __inner_statics_apple_generic {
229229 {
230230 @image_info;
231231 $image_info_section: literal;
232- $( $idents : ident ) +
232+ $hash : expr ;
233233 } => {
234234 /// We always emit the image info tag, since we need it to:
235235 /// - End up in the same codegen unit as the other statics below.
@@ -241,19 +241,19 @@ macro_rules! __inner_statics_apple_generic {
241241 #[ link_section = $image_info_section]
242242 #[ export_name = $crate:: __macro_helpers:: concat!(
243243 "\x01 L_OBJC_IMAGE_INFO_" ,
244- $crate :: __macro_helpers :: __hash_idents! ( $ ( $idents ) + ) ,
244+ $hash ,
245245 ) ]
246246 #[ used] // Make sure this reaches the linker
247247 static _IMAGE_INFO: $crate:: ffi:: __ImageInfo = $crate:: ffi:: __ImageInfo:: system( ) ;
248248 } ;
249249 {
250250 @module_info;
251- $( $idents : ident ) +
251+ $hash : expr ;
252252 } => {
253253 #[ link_section = "__TEXT,__cstring,cstring_literals" ]
254254 #[ export_name = $crate:: __macro_helpers:: concat!(
255255 "\x01 L_OBJC_CLASS_NAME_" ,
256- $crate :: __macro_helpers :: __hash_idents! ( $ ( $idents ) + ) ,
256+ $hash ,
257257 "_MODULE_INFO"
258258 ) ]
259259 static MODULE_INFO_NAME : [ $crate:: __macro_helpers:: u8 ; 1 ] = [ 0 ] ;
@@ -265,7 +265,7 @@ macro_rules! __inner_statics_apple_generic {
265265 #[ link_section = "__OBJC,__module_info,regular,no_dead_strip" ]
266266 #[ export_name = $crate:: __macro_helpers:: concat!(
267267 "\x01 L_OBJC_MODULES_" ,
268- $crate :: __macro_helpers :: __hash_idents! ( $ ( $idents ) + )
268+ $hash ,
269269 ) ]
270270 #[ used] // Make sure this reaches the linker
271271 static _MODULE_INFO: $crate:: __macro_helpers:: ModuleInfo = $crate:: __macro_helpers:: ModuleInfo :: new(
@@ -276,8 +276,8 @@ macro_rules! __inner_statics_apple_generic {
276276 @sel;
277277 $var_name_section: literal;
278278 $selector_ref_section: literal;
279- $data: expr,
280- $( $idents : ident ) +
279+ $data: expr;
280+ $hash : expr ;
281281 } => {
282282 use $crate:: __macro_helpers:: { u8 , UnsafeCell } ;
283283 use $crate:: runtime:: Sel ;
@@ -290,7 +290,7 @@ macro_rules! __inner_statics_apple_generic {
290290 #[ link_section = $var_name_section]
291291 #[ export_name = $crate:: __macro_helpers:: concat!(
292292 "\x01 L_OBJC_METH_VAR_NAME_" ,
293- $crate :: __macro_helpers :: __hash_idents! ( $ ( $idents ) + ) ,
293+ $hash ,
294294 ) ]
295295 static NAME_DATA : [ u8 ; X . len( ) ] = $crate:: __inner_statics_apple_generic! {
296296 @string_to_known_length_bytes;
@@ -323,15 +323,16 @@ macro_rules! __inner_statics_apple_generic {
323323 #[ link_section = $selector_ref_section]
324324 #[ export_name = $crate:: __macro_helpers:: concat!(
325325 "\x01 L_OBJC_SELECTOR_REFERENCES_" ,
326- $crate :: __macro_helpers :: __hash_idents! ( $ ( $idents ) + ) ,
326+ $hash ,
327327 ) ]
328328 static mut REF : UnsafeCell <Sel > = unsafe {
329329 UnsafeCell :: new( Sel :: __internal_from_ptr( NAME_DATA . as_ptr( ) . cast( ) ) )
330330 } ;
331331 } ;
332332 {
333333 @class;
334- $name: ident
334+ $name: ident;
335+ $hash: expr;
335336 } => {
336337 use $crate:: __macro_helpers:: UnsafeCell ;
337338 use $crate:: runtime:: Class ;
@@ -366,15 +367,16 @@ macro_rules! __inner_statics_apple_generic {
366367 #[ link_section = "__DATA,__objc_classrefs,regular,no_dead_strip" ]
367368 #[ export_name = $crate:: __macro_helpers:: concat!(
368369 "\x01 L_OBJC_CLASSLIST_REFERENCES_$_" ,
369- $crate:: __macro_helpers :: __hash_idents!( $name) ,
370+ $crate:: __hash_idents!( $name) ,
370371 ) ]
371372 static mut REF : UnsafeCell <& Class > = unsafe {
372373 UnsafeCell :: new( & CLASS )
373374 } ;
374375 } ;
375376 {
376377 @class_old;
377- $name: ident
378+ $name: ident;
379+ $hash: expr;
378380 } => {
379381 use $crate:: __macro_helpers:: { u8 , UnsafeCell } ;
380382 use $crate:: runtime:: Class ;
@@ -385,7 +387,7 @@ macro_rules! __inner_statics_apple_generic {
385387 #[ link_section = "__TEXT,__cstring,cstring_literals" ]
386388 #[ export_name = $crate:: __macro_helpers:: concat!(
387389 "\x01 L_OBJC_CLASS_NAME_" ,
388- $crate:: __macro_helpers :: __hash_idents!( $name) ,
390+ $crate:: __hash_idents!( $name) ,
389391 ) ]
390392 static NAME_DATA : [ u8 ; X . len( ) ] = $crate:: __inner_statics_apple_generic! {
391393 @string_to_known_length_bytes;
@@ -396,7 +398,7 @@ macro_rules! __inner_statics_apple_generic {
396398 #[ link_section = "__OBJC,__cls_refs,literal_pointers,no_dead_strip" ]
397399 #[ export_name = $crate:: __macro_helpers:: concat!(
398400 "\x01 L_OBJC_CLASS_REFERENCES_" ,
399- $crate:: __macro_helpers :: __hash_idents!( $name) ,
401+ $crate:: __hash_idents!( $name) ,
400402 ) ]
401403 static mut REF : UnsafeCell <& Class > = unsafe {
402404 let ptr: * const Class = NAME_DATA . as_ptr( ) . cast( ) ;
@@ -410,28 +412,30 @@ macro_rules! __inner_statics_apple_generic {
410412#[ macro_export]
411413#[ cfg( all( feature = "apple" , not( all( target_os = "macos" , target_arch = "x86" ) ) ) ) ]
412414macro_rules! __inner_statics {
413- ( @image_info $( $args : tt ) * ) => {
415+ ( @image_info $hash : expr ) => {
414416 $crate:: __inner_statics_apple_generic! {
415417 @image_info;
416418 "__DATA,__objc_imageinfo,regular,no_dead_strip" ;
417- $( $args ) *
419+ $hash ;
418420 }
419421 } ;
420- ( @sel $( $args : tt ) * ) => {
422+ ( @sel $data : expr , $hash : expr ) => {
421423 $crate:: __inner_statics_apple_generic! {
422424 @sel;
423425 "__TEXT,__objc_methname,cstring_literals" ;
424426 // Clang uses `no_dead_strip` in the link section for some reason,
425427 // which other tools (notably some LLVM tools) now assume is
426428 // present, so we have to add it as well.
427429 "__DATA,__objc_selrefs,literal_pointers,no_dead_strip" ;
428- $( $args) *
430+ $data;
431+ $hash;
429432 }
430433 } ;
431- ( @class $( $args : tt ) * ) => {
434+ ( @class $name : ident , $hash : expr ) => {
432435 $crate:: __inner_statics_apple_generic! {
433436 @class;
434- $( $args) *
437+ $name;
438+ $hash;
435439 }
436440 } ;
437441}
@@ -440,29 +444,31 @@ macro_rules! __inner_statics {
440444#[ macro_export]
441445#[ cfg( all( feature = "apple" , target_os = "macos" , target_arch = "x86" ) ) ]
442446macro_rules! __inner_statics {
443- ( @image_info $( $args : tt ) * ) => {
447+ ( @image_info $hash : expr ) => {
444448 $crate:: __inner_statics_apple_generic! {
445449 @image_info;
446450 "__OBJC,__image_info,regular" ;
447- $( $args ) *
451+ $hash ;
448452 }
449453 } ;
450- ( @sel $( $args : tt ) * ) => {
454+ ( @sel $data : expr , $hash : expr ) => {
451455 $crate:: __inner_statics_apple_generic! {
452456 @sel;
453457 "__TEXT,__cstring,cstring_literals" ;
454458 "__OBJC,__message_refs,literal_pointers,no_dead_strip" ;
455- $( $args) *
459+ $data;
460+ $hash;
456461 }
457462 } ;
458- ( @class $( $args : tt ) * ) => {
463+ ( @class $name : ident , $hash : expr ) => {
459464 $crate:: __inner_statics_apple_generic! {
460465 @class_old;
461- $( $args) *
466+ $name;
467+ $hash;
462468 }
463469 $crate:: __inner_statics_apple_generic! {
464470 @module_info;
465- $( $args ) *
471+ $hash ;
466472 }
467473 } ;
468474}
@@ -495,9 +501,9 @@ macro_rules! __inner_statics {
495501 not( feature = "unstable-static-sel-inlined" )
496502) ) ]
497503macro_rules! __sel_inner {
498- ( $data: expr, $( $idents : ident ) + ) => { {
499- $crate:: __inner_statics!( @image_info $( $idents ) + ) ;
500- $crate:: __inner_statics!( @sel $data, $( $idents ) + ) ;
504+ ( $data: expr, $hash : expr ) => { {
505+ $crate:: __inner_statics!( @image_info $hash ) ;
506+ $crate:: __inner_statics!( @sel $data, $hash ) ;
501507
502508 /// HACK: Wrap the access in a non-generic, `#[inline(never)]`
503509 /// function to make the compiler group it into the same codegen unit
@@ -524,9 +530,9 @@ macro_rules! __sel_inner {
524530#[ macro_export]
525531#[ cfg( all( feature = "unstable-static-sel-inlined" ) ) ]
526532macro_rules! __sel_inner {
527- ( $data: expr, $( $idents : ident ) + ) => { {
528- $crate:: __inner_statics!( @image_info $( $idents ) + ) ;
529- $crate:: __inner_statics!( @sel $data, $( $idents ) + ) ;
533+ ( $data: expr, $hash : expr ) => { {
534+ $crate:: __inner_statics!( @image_info $hash ) ;
535+ $crate:: __inner_statics!( @sel $data, $hash ) ;
530536
531537 #[ allow( unused_unsafe) ]
532538 // SAFETY: See above
@@ -541,9 +547,9 @@ macro_rules! __sel_inner {
541547 not( feature = "unstable-static-class-inlined" )
542548) ) ]
543549macro_rules! __class_inner {
544- ( $name: ident) => { {
545- $crate:: __inner_statics!( @image_info $name ) ;
546- $crate:: __inner_statics!( @class $name) ;
550+ ( $name: ident, $hash : expr ) => { {
551+ $crate:: __inner_statics!( @image_info $hash ) ;
552+ $crate:: __inner_statics!( @class $name, $hash ) ;
547553
548554 #[ inline( never) ]
549555 fn objc_static_workaround( ) -> & ' static Class {
@@ -559,9 +565,9 @@ macro_rules! __class_inner {
559565#[ macro_export]
560566#[ cfg( all( feature = "unstable-static-class-inlined" ) ) ]
561567macro_rules! __class_inner {
562- ( $name: ident) => { {
563- $crate:: __inner_statics!( @image_info $name ) ;
564- $crate:: __inner_statics!( @class $name) ;
568+ ( $name: ident, $hash : expr ) => { {
569+ $crate:: __inner_statics!( @image_info $hash ) ;
570+ $crate:: __inner_statics!( @class $name, $hash ) ;
565571
566572 #[ allow( unused_unsafe) ]
567573 // SAFETY: See above
0 commit comments