@@ -2,8 +2,10 @@ use crate::rc::{Id, Ownership};
22use crate :: runtime:: { Class , Sel } ;
33use crate :: { Message , MessageArguments , MessageError , MessageReceiver } ;
44
5- # [ doc ( hidden ) ]
5+ pub use core :: cell :: UnsafeCell ;
66pub use core:: compile_error;
7+ #[ cfg( feature = "unstable-static-sel" ) ]
8+ pub use objc2_proc_macros:: __hash_idents;
79
810/// Helper for specifying the retain semantics for a given selector family.
911///
@@ -28,7 +30,6 @@ pub use core::compile_error;
2830/// ARC though!
2931///
3032/// <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#retainable-object-pointers-as-operands-and-arguments>
31- #[ doc( hidden) ]
3233pub struct RetainSemantics <
3334 // `new` family
3435 const NEW : bool ,
@@ -40,7 +41,6 @@ pub struct RetainSemantics<
4041 const COPY_OR_MUT_COPY : bool ,
4142> { }
4243
43- #[ doc( hidden) ]
4444pub trait MsgSendId < T , U > {
4545 unsafe fn send_message_id < A : MessageArguments > (
4646 obj : T ,
@@ -131,7 +131,6 @@ impl<T: MessageReceiver, U: Message, O: Ownership> MsgSendId<T, Id<U, O>>
131131/// Checks whether a given selector is said to be in a given selector family.
132132///
133133/// <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-method-families>
134- #[ doc( hidden) ]
135134pub const fn in_selector_family ( mut selector : & [ u8 ] , mut family : & [ u8 ] ) -> bool {
136135 // Skip leading underscores from selector
137136 loop {
@@ -373,4 +372,31 @@ mod tests {
373372 let _obj: Id < Object , Owned > = unsafe { msg_send_id ! [ cls, new] . unwrap ( ) } ;
374373 }
375374 }
375+
376+ #[ test]
377+ #[ cfg( feature = "objc2-proc-macros" ) ]
378+ fn hash_idents_different ( ) {
379+ assert_ne ! ( __hash_idents!( abc) , __hash_idents!( def) ) ;
380+ }
381+
382+ #[ test]
383+ #[ cfg( feature = "objc2-proc-macros" ) ]
384+ fn hash_idents_same_no_equal ( ) {
385+ assert_ne ! ( __hash_idents!( abc) , __hash_idents!( abc) ) ;
386+ assert_ne ! ( __hash_idents!( abc def ghi) , __hash_idents!( abc def ghi) ) ;
387+ }
388+
389+ #[ test]
390+ #[ cfg( feature = "objc2-proc-macros" ) ]
391+ fn hash_idents_exact_same_ident ( ) {
392+ macro_rules! x {
393+ ( $x: ident) => {
394+ ( __hash_idents!( $x) , __hash_idents!( $x) )
395+ } ;
396+ }
397+ let ( ident1, ident2) = x ! ( abc) ;
398+ // This is a limitation of `__hash_idents`, ideally we'd like these
399+ // to be different!
400+ assert_eq ! ( ident1, ident2) ;
401+ }
376402}
0 commit comments