@@ -727,24 +727,42 @@ unsafe impl Send for TypeId {}
727
727
unsafe impl Sync for TypeId { }
728
728
729
729
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord ) ]
730
- struct TypeIdData {
730
+ pub ( crate ) struct TypeIdData {
731
731
full_hash : [ u8 ; 16 ] ,
732
732
}
733
733
734
734
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
735
- impl PartialEq for TypeId {
735
+ #[ rustc_const_unstable( feature = "const_type_id" , issue = "77125" ) ]
736
+ impl const PartialEq for TypeId {
736
737
#[ inline]
737
738
fn eq ( & self , other : & Self ) -> bool {
738
- self . data as * const TypeIdData == other. data as * const TypeIdData
739
- || ( self . partial_hash == other. partial_hash
740
- && self . data . full_hash == other. data . full_hash )
739
+ const fn ct ( a : & TypeId , b : & TypeId ) -> bool {
740
+ crate :: intrinsics:: type_id_eq ( * a, * b)
741
+ }
742
+
743
+ #[ inline]
744
+ fn rt ( a : & TypeId , b : & TypeId ) -> bool {
745
+ a. data as * const TypeIdData == b. data as * const TypeIdData
746
+ || ( a. partial_hash == b. partial_hash && a. data . full_hash == b. data . full_hash )
747
+ }
748
+
749
+ core:: intrinsics:: const_eval_select ( ( self , other) , ct, rt)
741
750
}
742
751
743
752
#[ inline]
744
753
fn ne ( & self , other : & Self ) -> bool {
745
- self . partial_hash != other. partial_hash
746
- || ( self . data as * const TypeIdData != other. data as * const TypeIdData
747
- && self . data . full_hash != other. data . full_hash )
754
+ const fn ct ( a : & TypeId , b : & TypeId ) -> bool {
755
+ !crate :: intrinsics:: type_id_eq ( * a, * b)
756
+ }
757
+
758
+ #[ inline]
759
+ fn rt ( a : & TypeId , b : & TypeId ) -> bool {
760
+ a. partial_hash != b. partial_hash
761
+ || ( a. data as * const TypeIdData != b. data as * const TypeIdData
762
+ && a. data . full_hash != b. data . full_hash )
763
+ }
764
+
765
+ core:: intrinsics:: const_eval_select ( ( self , other) , ct, rt)
748
766
}
749
767
}
750
768
0 commit comments