diff options
| author | bors <bors@rust-lang.org> | 2022-05-29 16:28:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-29 16:28:21 +0000 |
| commit | bef2b7cd1c7bcb3393f10d5752fcf9ee3026bce8 (patch) | |
| tree | 69cee0fee5ca2644af4dfdea4ae7a966ad416f0a /library/alloc/src | |
| parent | 9d1aeaeb827da7a10b7cfaccf0a1d6ebf414a7b5 (diff) | |
| parent | b454991ac4eef89480679f595cbe81e0d5e23262 (diff) | |
| download | rust-bef2b7cd1c7bcb3393f10d5752fcf9ee3026bce8.tar.gz rust-bef2b7cd1c7bcb3393f10d5752fcf9ee3026bce8.zip | |
Auto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbini
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. This now brings us to cfg-clean, with the exception of check-cfg-features in bootstrap; I'd prefer to leave that for a separate PR at this time since it's likely to be more tricky. cc https://github.com/rust-lang/rust/pull/97147#issuecomment-1132845061 r? `@pietroalbini`
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() |
