@@ -94,7 +94,7 @@ use crate::str;
9494/// ```
9595///
9696/// [str]: prim@str "str"
97- #[ derive( Hash ) ]
97+ #[ derive( PartialEq , Eq , Hash ) ]
9898#[ stable( feature = "core_c_str" , since = "1.64.0" ) ]
9999#[ rustc_has_incoherent_inherent_impls]
100100#[ lang = "CStr" ]
@@ -104,7 +104,6 @@ use crate::str;
104104// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
105105// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
106106#[ repr( transparent) ]
107- #[ allow( clippy:: derived_hash_with_manual_eq) ]
108107pub struct CStr {
109108 // FIXME: this should not be represented with a DST slice but rather with
110109 // just a raw `c_char` along with some form of marker to make
@@ -678,15 +677,9 @@ impl CStr {
678677 }
679678}
680679
681- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
682- impl PartialEq for CStr {
683- #[ inline]
684- fn eq ( & self , other : & CStr ) -> bool {
685- self . to_bytes ( ) . eq ( other. to_bytes ( ) )
686- }
687- }
688- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
689- impl Eq for CStr { }
680+ // `.to_bytes()` representations are compared instead of the inner `[c_char]`s,
681+ // because `c_char` is `i8` (not `u8`) on some platforms.
682+ // That is why this is implemented manually and not derived.
690683#[ stable( feature = "rust1" , since = "1.0.0" ) ]
691684impl PartialOrd for CStr {
692685 #[ inline]
0 commit comments