From 22407dcfff0595c35fbddfb3b3c4530e17adf802 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 28 Jun 2025 15:47:45 -0700 Subject: [PATCH] Revert "Rollup merge of #137268 - bjoernager:c-string-eq-c-str, r=Amanieu" This reverts commit 30550c048d0d15a91ecd678f265d331531d49f7b, reversing changes made to 36b21637e93b038453924d3c66821089e71d8baa. --- library/alloc/src/ffi/c_str.rs | 109 --------------------------------- library/core/src/ffi/c_str.rs | 14 ----- 2 files changed, 123 deletions(-) diff --git a/library/alloc/src/ffi/c_str.rs b/library/alloc/src/ffi/c_str.rs index 93bdad7538007..48849bf7536c0 100644 --- a/library/alloc/src/ffi/c_str.rs +++ b/library/alloc/src/ffi/c_str.rs @@ -1099,46 +1099,6 @@ impl From<&CStr> for CString { } } -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq for CString { - #[inline] - fn eq(&self, other: &CStr) -> bool { - **self == *other - } - - #[inline] - fn ne(&self, other: &CStr) -> bool { - **self != *other - } -} - -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq<&CStr> for CString { - #[inline] - fn eq(&self, other: &&CStr) -> bool { - **self == **other - } - - #[inline] - fn ne(&self, other: &&CStr) -> bool { - **self != **other - } -} - -#[cfg(not(no_global_oom_handling))] -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq> for CString { - #[inline] - fn eq(&self, other: &Cow<'_, CStr>) -> bool { - **self == **other - } - - #[inline] - fn ne(&self, other: &Cow<'_, CStr>) -> bool { - **self != **other - } -} - #[stable(feature = "cstring_asref", since = "1.7.0")] impl ops::Index for CString { type Output = CStr; @@ -1221,75 +1181,6 @@ impl CStr { } } -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq for CStr { - #[inline] - fn eq(&self, other: &CString) -> bool { - *self == **other - } - - #[inline] - fn ne(&self, other: &CString) -> bool { - *self != **other - } -} - -#[cfg(not(no_global_oom_handling))] -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq> for CStr { - #[inline] - fn eq(&self, other: &Cow<'_, Self>) -> bool { - *self == **other - } - - #[inline] - fn ne(&self, other: &Cow<'_, Self>) -> bool { - *self != **other - } -} - -#[cfg(not(no_global_oom_handling))] -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq for Cow<'_, CStr> { - #[inline] - fn eq(&self, other: &CStr) -> bool { - **self == *other - } - - #[inline] - fn ne(&self, other: &CStr) -> bool { - **self != *other - } -} - -#[cfg(not(no_global_oom_handling))] -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq<&CStr> for Cow<'_, CStr> { - #[inline] - fn eq(&self, other: &&CStr) -> bool { - **self == **other - } - - #[inline] - fn ne(&self, other: &&CStr) -> bool { - **self != **other - } -} - -#[cfg(not(no_global_oom_handling))] -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq for Cow<'_, CStr> { - #[inline] - fn eq(&self, other: &CString) -> bool { - **self == **other - } - - #[inline] - fn ne(&self, other: &CString) -> bool { - **self != **other - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl core::error::Error for NulError { #[allow(deprecated)] diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 881a7a24083c8..12d8e8a2573d1 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -660,19 +660,6 @@ impl CStr { } } -#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] -impl PartialEq<&Self> for CStr { - #[inline] - fn eq(&self, other: &&Self) -> bool { - *self == **other - } - - #[inline] - fn ne(&self, other: &&Self) -> bool { - *self != **other - } -} - // `.to_bytes()` representations are compared instead of the inner `[c_char]`s, // because `c_char` is `i8` (not `u8`) on some platforms. // That is why this is implemented manually and not derived. @@ -683,7 +670,6 @@ impl PartialOrd for CStr { self.to_bytes().partial_cmp(&other.to_bytes()) } } - #[stable(feature = "rust1", since = "1.0.0")] impl Ord for CStr { #[inline]