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`
This commit is contained in:
bors 2022-05-29 16:28:21 +00:00
commit bef2b7cd1c
19 changed files with 347 additions and 466 deletions

View file

@ -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 <20>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>.

View file

@ -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")]

View file

@ -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()

View file

@ -77,7 +77,7 @@ use crate::str;
#[derive(Hash)]
#[cfg_attr(not(test), rustc_diagnostic_item = "CStr")]
#[unstable(feature = "core_c_str", issue = "94079")]
#[cfg_attr(not(bootstrap), rustc_has_incoherent_inherent_impls)]
#[rustc_has_incoherent_inherent_impls]
// FIXME:
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies
// on `CStr` being layout-compatible with `[u8]`.

View file

@ -1908,7 +1908,6 @@ extern "rust-intrinsic" {
/// See documentation of `<*const T>::sub_ptr` for details.
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[cfg(not(bootstrap))]
pub fn ptr_offset_from_unsigned<T>(ptr: *const T, base: *const T) -> usize;
/// See documentation of `<*const T>::guaranteed_eq` for details.
@ -2393,11 +2392,3 @@ where
{
called_in_const.call_once(arg)
}
/// Bootstrap polyfill
#[cfg(bootstrap)]
pub const unsafe fn ptr_offset_from_unsigned<T>(ptr: *const T, base: *const T) -> usize {
// SAFETY: we have stricter preconditions than `ptr_offset_from`, so can
// call it, and its output has to be positive, so we can just cast.
unsafe { ptr_offset_from(ptr, base) as _ }
}

View file

@ -330,7 +330,6 @@ pub trait FromResidual<R = <Self as Try>::Residual> {
fn from_residual(residual: R) -> Self;
}
#[cfg(not(bootstrap))]
#[unstable(
feature = "yeet_desugar_details",
issue = "none",

View file

@ -62,7 +62,6 @@ extern "platform-intrinsic" {
pub(crate) fn simd_xor<T>(x: T, y: T) -> T;
/// getelementptr (without inbounds)
#[cfg(not(bootstrap))]
pub(crate) fn simd_arith_offset<T, U>(ptrs: T, offsets: U) -> T;
/// fptoui/fptosi/uitofp/sitofp

View file

@ -1,9 +1,6 @@
//! Private implementation details of public gather/scatter APIs.
#[cfg(not(bootstrap))]
use crate::simd::intrinsics;
use crate::simd::{LaneCount, Simd, SupportedLaneCount};
#[cfg(bootstrap)]
use core::mem;
/// A vector of *const T.
#[derive(Debug, Copy, Clone)]
@ -24,14 +21,6 @@ where
#[inline]
#[must_use]
pub fn wrapping_add(self, addend: Simd<usize, LANES>) -> Self {
#[cfg(bootstrap)]
// Safety: converting pointers to usize and vice-versa is safe
// (even if using that pointer is not)
unsafe {
let x: Simd<usize, LANES> = mem::transmute_copy(&self);
mem::transmute_copy(&{ x + (addend * Simd::splat(mem::size_of::<T>())) })
}
#[cfg(not(bootstrap))]
// Safety: this intrinsic doesn't have a precondition
unsafe { intrinsics::simd_arith_offset(self, addend) }
}
@ -56,14 +45,6 @@ where
#[inline]
#[must_use]
pub fn wrapping_add(self, addend: Simd<usize, LANES>) -> Self {
#[cfg(bootstrap)]
// Safety: converting pointers to usize and vice-versa is safe
// (even if using that pointer is not)
unsafe {
let x: Simd<usize, LANES> = mem::transmute_copy(&self);
mem::transmute_copy(&{ x + (addend * Simd::splat(mem::size_of::<T>())) })
}
#[cfg(not(bootstrap))]
// Safety: this intrinsic doesn't have a precondition
unsafe { intrinsics::simd_arith_offset(self, addend) }
}

View file

@ -95,7 +95,3 @@ pub use crate::string::{String, ToString};
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(no_inline)]
pub use crate::vec::Vec;
#[cfg(bootstrap)]
#[unstable(feature = "cstr_internals", issue = "none")]
pub use alloc::ffi::CStrExt;