diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-05-20 08:54:10 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-05-27 07:36:17 -0400 |
| commit | b454991ac4eef89480679f595cbe81e0d5e23262 (patch) | |
| tree | 8bea6122df07ce3dc72bd5733b2bff389a17c7d1 /library/alloc/src | |
| parent | 46147119ec545045948bc799581d93edd3b1617b (diff) | |
| download | rust-b454991ac4eef89480679f595cbe81e0d5e23262.tar.gz rust-b454991ac4eef89480679f595cbe81e0d5e23262.zip | |
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.
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/ffi/c_str.rs | 78 | ||||
| -rw-r--r-- | library/alloc/src/ffi/mod.rs | 3 | ||||
| -rw-r--r-- | library/alloc/src/macros.rs | 2 |
3 files changed, 1 insertions, 82 deletions
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<CStr> for CString { } } -#[cfg(bootstrap)] -#[doc(hidden)] -#[unstable(feature = "cstr_internals", issue = "none")] -pub trait CStrExt { - /// Converts a `CStr` into a <code>[Cow]<[str]></code>. - /// - /// If the contents of the `CStr` are valid UTF-8 data, this - /// function will return a <code>[Cow]::[Borrowed]\(&[str])</code> - /// with the corresponding <code>&[str]</code> slice. Otherwise, it will - /// replace any invalid UTF-8 sequences with - /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a - /// <code>[Cow]::[Owned]\(&[str])</code> 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 <code>[Box]<[CStr]></code> 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<Self>) -> 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<Self>) -> CString { - CString::from(self) - } -} - -#[cfg(not(bootstrap))] #[cfg(not(test))] impl CStr { /// Converts a `CStr` into a <code>[Cow]<[str]></code>. 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() |
