Rollup merge of #118398 - mu001999:std/add_cfgs, r=thomcc

Add proper cfgs in std

Detected by #118257
This commit is contained in:
Matthias Krüger 2023-11-29 04:23:23 +01:00 committed by GitHub
commit b7016ae205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 0 deletions

View File

@ -423,12 +423,14 @@ pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
} }
} }
#[cfg(not(no_global_oom_handling))]
/// Specialize clones into pre-allocated, uninitialized memory. /// Specialize clones into pre-allocated, uninitialized memory.
/// Used by `Box::clone` and `Rc`/`Arc::make_mut`. /// Used by `Box::clone` and `Rc`/`Arc::make_mut`.
pub(crate) trait WriteCloneIntoRaw: Sized { pub(crate) trait WriteCloneIntoRaw: Sized {
unsafe fn write_clone_into_raw(&self, target: *mut Self); unsafe fn write_clone_into_raw(&self, target: *mut Self);
} }
#[cfg(not(no_global_oom_handling))]
impl<T: Clone> WriteCloneIntoRaw for T { impl<T: Clone> WriteCloneIntoRaw for T {
#[inline] #[inline]
default unsafe fn write_clone_into_raw(&self, target: *mut Self) { default unsafe fn write_clone_into_raw(&self, target: *mut Self) {
@ -438,6 +440,7 @@ impl<T: Clone> WriteCloneIntoRaw for T {
} }
} }
#[cfg(not(no_global_oom_handling))]
impl<T: Copy> WriteCloneIntoRaw for T { impl<T: Copy> WriteCloneIntoRaw for T {
#[inline] #[inline]
unsafe fn write_clone_into_raw(&self, target: *mut Self) { unsafe fn write_clone_into_raw(&self, target: *mut Self) {

View File

@ -148,6 +148,7 @@ fn fmt(
/// An intermediate trait for specialization of `Extend`. /// An intermediate trait for specialization of `Extend`.
#[doc(hidden)] #[doc(hidden)]
#[cfg(not(no_global_oom_handling))]
trait SpecExtend<I: IntoIterator> { trait SpecExtend<I: IntoIterator> {
/// Extends `self` with the contents of the given iterator. /// Extends `self` with the contents of the given iterator.
fn spec_extend(&mut self, iter: I); fn spec_extend(&mut self, iter: I);

View File

@ -2023,6 +2023,7 @@ unsafe fn allocate_for_slice_in(len: usize, alloc: &A) -> *mut RcBox<[T]> {
} }
} }
#[cfg(not(no_global_oom_handling))]
/// Specialization trait used for `From<&[T]>`. /// Specialization trait used for `From<&[T]>`.
trait RcFromSlice<T> { trait RcFromSlice<T> {
fn from_slice(slice: &[T]) -> Self; fn from_slice(slice: &[T]) -> Self;

View File

@ -3503,6 +3503,7 @@ fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
} }
} }
#[cfg(not(no_global_oom_handling))]
/// Specialization trait used for collecting into `Arc<[T]>`. /// Specialization trait used for collecting into `Arc<[T]>`.
trait ToArcSlice<T>: Iterator<Item = T> + Sized { trait ToArcSlice<T>: Iterator<Item = T> + Sized {
fn to_arc_slice(self) -> Arc<[T]>; fn to_arc_slice(self) -> Arc<[T]>;

View File

@ -58,6 +58,7 @@
use core::cmp::Ordering; use core::cmp::Ordering;
use core::fmt; use core::fmt;
use core::hash::{Hash, Hasher}; use core::hash::{Hash, Hasher};
#[cfg(not(no_global_oom_handling))]
use core::iter; use core::iter;
use core::marker::PhantomData; use core::marker::PhantomData;
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties}; use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
@ -101,6 +102,7 @@
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
use self::is_zero::IsZero; use self::is_zero::IsZero;
#[cfg(not(no_global_oom_handling))]
mod is_zero; mod is_zero;
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
@ -2599,6 +2601,7 @@ pub fn from_elem_in<T: Clone, A: Allocator>(elem: T, n: usize, alloc: A) -> Vec<
<T as SpecFromElem>::from_elem(elem, n, alloc) <T as SpecFromElem>::from_elem(elem, n, alloc)
} }
#[cfg(not(no_global_oom_handling))]
trait ExtendFromWithinSpec { trait ExtendFromWithinSpec {
/// # Safety /// # Safety
/// ///
@ -2607,6 +2610,7 @@ trait ExtendFromWithinSpec {
unsafe fn spec_extend_from_within(&mut self, src: Range<usize>); unsafe fn spec_extend_from_within(&mut self, src: Range<usize>);
} }
#[cfg(not(no_global_oom_handling))]
impl<T: Clone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> { impl<T: Clone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
default unsafe fn spec_extend_from_within(&mut self, src: Range<usize>) { default unsafe fn spec_extend_from_within(&mut self, src: Range<usize>) {
// SAFETY: // SAFETY:
@ -2626,6 +2630,7 @@ impl<T: Clone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
} }
} }
#[cfg(not(no_global_oom_handling))]
impl<T: Copy, A: Allocator> ExtendFromWithinSpec for Vec<T, A> { impl<T: Copy, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
unsafe fn spec_extend_from_within(&mut self, src: Range<usize>) { unsafe fn spec_extend_from_within(&mut self, src: Range<usize>) {
let count = src.len(); let count = src.len();