From b454991ac4eef89480679f595cbe81e0d5e23262 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 20 May 2022 08:54:10 -0400 Subject: Finish bumping stage0 It looks like the last time had left some remaining cfg's -- which made me think that the stage0 bump was actually successful. This brings us to a released 1.62 beta though. --- library/alloc/src/ffi/c_str.rs | 78 ------------------------------------------ library/alloc/src/ffi/mod.rs | 3 -- library/alloc/src/macros.rs | 2 +- 3 files changed, 1 insertion(+), 82 deletions(-) (limited to 'library/alloc') diff --git a/library/alloc/src/ffi/c_str.rs b/library/alloc/src/ffi/c_str.rs index 172a008e89a..cde4219be84 100644 --- a/library/alloc/src/ffi/c_str.rs +++ b/library/alloc/src/ffi/c_str.rs @@ -1053,84 +1053,6 @@ impl AsRef for CString { } } -#[cfg(bootstrap)] -#[doc(hidden)] -#[unstable(feature = "cstr_internals", issue = "none")] -pub trait CStrExt { - /// Converts a `CStr` into a [Cow]<[str]>. - /// - /// If the contents of the `CStr` are valid UTF-8 data, this - /// function will return a [Cow]::[Borrowed]\(&[str]) - /// with the corresponding &[str] slice. Otherwise, it will - /// replace any invalid UTF-8 sequences with - /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a - /// [Cow]::[Owned]\(&[str]) with the result. - /// - /// [str]: prim@str "str" - /// [Borrowed]: Cow::Borrowed - /// [Owned]: Cow::Owned - /// [U+FFFD]: crate::char::REPLACEMENT_CHARACTER "std::char::REPLACEMENT_CHARACTER" - /// - /// # Examples - /// - /// Calling `to_string_lossy` on a `CStr` containing valid UTF-8: - /// - /// ``` - /// use std::borrow::Cow; - /// use std::ffi::CStr; - /// - /// let cstr = CStr::from_bytes_with_nul(b"Hello World\0") - /// .expect("CStr::from_bytes_with_nul failed"); - /// assert_eq!(cstr.to_string_lossy(), Cow::Borrowed("Hello World")); - /// ``` - /// - /// Calling `to_string_lossy` on a `CStr` containing invalid UTF-8: - /// - /// ``` - /// use std::borrow::Cow; - /// use std::ffi::CStr; - /// - /// let cstr = CStr::from_bytes_with_nul(b"Hello \xF0\x90\x80World\0") - /// .expect("CStr::from_bytes_with_nul failed"); - /// assert_eq!( - /// cstr.to_string_lossy(), - /// Cow::Owned(String::from("Hello �World")) as Cow<'_, str> - /// ); - /// ``` - #[must_use = "this returns the result of the operation, \ - without modifying the original"] - #[stable(feature = "cstr_to_str", since = "1.4.0")] - fn to_string_lossy(&self) -> Cow<'_, str>; - - /// Converts a [Box]<[CStr]> into a [`CString`] without copying or allocating. - /// - /// # Examples - /// - /// ``` - /// use std::ffi::CString; - /// - /// let c_string = CString::new(b"foo".to_vec()).expect("CString::new failed"); - /// let boxed = c_string.into_boxed_c_str(); - /// assert_eq!(boxed.into_c_string(), CString::new("foo").expect("CString::new failed")); - /// ``` - #[must_use = "`self` will be dropped if the result is not used"] - #[stable(feature = "into_boxed_c_str", since = "1.20.0")] - fn into_c_string(self: Box) -> CString; -} - -#[cfg(bootstrap)] -#[unstable(feature = "cstr_internals", issue = "none")] -impl CStrExt for CStr { - fn to_string_lossy(&self) -> Cow<'_, str> { - String::from_utf8_lossy(self.to_bytes()) - } - - fn into_c_string(self: Box) -> CString { - CString::from(self) - } -} - -#[cfg(not(bootstrap))] #[cfg(not(test))] impl CStr { /// Converts a `CStr` into a [Cow]<[str]>. diff --git a/library/alloc/src/ffi/mod.rs b/library/alloc/src/ffi/mod.rs index eed2851c153..fec2bec566a 100644 --- a/library/alloc/src/ffi/mod.rs +++ b/library/alloc/src/ffi/mod.rs @@ -80,9 +80,6 @@ #![unstable(feature = "alloc_ffi", issue = "94079")] -#[cfg(bootstrap)] -#[unstable(feature = "cstr_internals", issue = "none")] -pub use self::c_str::CStrExt; #[unstable(feature = "alloc_c_string", issue = "94079")] pub use self::c_str::FromVecWithNulError; #[unstable(feature = "alloc_c_string", issue = "94079")] diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index 093b02113c3..d9346daa109 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -56,7 +56,7 @@ macro_rules! vec { // `slice::into_vec` function which is only available with cfg(test) // NB see the slice::hack module in slice.rs for more information #[cfg(all(not(no_global_oom_handling), test))] -#[cfg_attr(not(bootstrap), allow(unused_macro_rules))] +#[allow(unused_macro_rules)] macro_rules! vec { () => ( $crate::vec::Vec::new() -- cgit 1.4.1-3-g733a5