@@ -2,8 +2,10 @@ use crate::rc::{Id, Ownership};
2
2
use crate :: runtime:: { Class , Sel } ;
3
3
use crate :: { Message , MessageArguments , MessageError , MessageReceiver } ;
4
4
5
- # [ doc ( hidden ) ]
5
+ pub use core :: cell :: UnsafeCell ;
6
6
pub use core:: compile_error;
7
+ #[ cfg( feature = "unstable-static-sel" ) ]
8
+ pub use objc2_proc_macros:: __hash_idents;
7
9
8
10
/// Helper for specifying the retain semantics for a given selector family.
9
11
///
@@ -28,7 +30,6 @@ pub use core::compile_error;
28
30
/// ARC though!
29
31
///
30
32
/// <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#retainable-object-pointers-as-operands-and-arguments>
31
- #[ doc( hidden) ]
32
33
pub struct RetainSemantics <
33
34
// `new` family
34
35
const NEW : bool ,
@@ -40,7 +41,6 @@ pub struct RetainSemantics<
40
41
const COPY_OR_MUT_COPY : bool ,
41
42
> { }
42
43
43
- #[ doc( hidden) ]
44
44
pub trait MsgSendId < T , U > {
45
45
unsafe fn send_message_id < A : MessageArguments > (
46
46
obj : T ,
@@ -131,7 +131,6 @@ impl<T: MessageReceiver, U: Message, O: Ownership> MsgSendId<T, Id<U, O>>
131
131
/// Checks whether a given selector is said to be in a given selector family.
132
132
///
133
133
/// <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-method-families>
134
- #[ doc( hidden) ]
135
134
pub const fn in_selector_family ( mut selector : & [ u8 ] , mut family : & [ u8 ] ) -> bool {
136
135
// Skip leading underscores from selector
137
136
loop {
@@ -373,4 +372,31 @@ mod tests {
373
372
let _obj: Id < Object , Owned > = unsafe { msg_send_id ! [ cls, new] . unwrap ( ) } ;
374
373
}
375
374
}
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
+ }
376
402
}
0 commit comments