Skip to content

Commit 2cbdee6

Browse files
committed
Add missing cfg-attributes for no-global-oom-handling in Rc and Arc
1 parent 42fe0b9 commit 2cbdee6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

library/alloc/src/rc.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@
242242
243243
#![stable(feature = "rust1", since = "1.0.0")]
244244

245-
#[cfg(not(test))]
245+
#[cfg(all(not(test), not(no_global_oom_handling)))]
246246
use crate::boxed::Box;
247-
#[cfg(test)]
247+
#[cfg(all(test, not(no_global_oom_handling)))]
248248
use std::boxed::Box;
249249

250250
use core::alloc::helper::{AllocInit, PrefixAllocator};
@@ -261,15 +261,14 @@ use core::iter;
261261
use core::marker::{self, PhantomData, Unpin, Unsize};
262262
use core::mem;
263263
use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
264+
#[cfg(not(no_global_oom_handling))]
264265
use core::pin::Pin;
265266
use core::ptr::{self, NonNull};
266267
#[cfg(not(no_global_oom_handling))]
267268
use core::slice::from_raw_parts_mut;
268269

269270
#[cfg(not(no_global_oom_handling))]
270-
use crate::alloc::handle_alloc_error;
271-
#[cfg(not(no_global_oom_handling))]
272-
use crate::alloc::{box_free, WriteCloneIntoRaw};
271+
use crate::alloc::{handle_alloc_error, box_free, WriteCloneIntoRaw};
273272
use crate::alloc::{AllocError, Allocator, Global, Layout};
274273
use crate::borrow::{Cow, ToOwned};
275274
#[cfg(not(no_global_oom_handling))]
@@ -661,6 +660,7 @@ impl<T> Rc<T> {
661660
/// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then
662661
/// `value` will be pinned in memory and unable to be moved.
663662
#[inline]
663+
#[cfg(not(no_global_oom_handling))]
664664
#[stable(feature = "pin", since = "1.33.0")]
665665
pub fn pin(value: T) -> Pin<Rc<T>> {
666666
unsafe { Pin::new_unchecked(Rc::new(value)) }
@@ -1552,6 +1552,7 @@ impl<T: ?Sized> Clone for Rc<T> {
15521552
}
15531553
}
15541554

1555+
#[cfg(not(no_global_oom_handling))]
15551556
#[stable(feature = "rust1", since = "1.0.0")]
15561557
impl<T: Default> Default for Rc<T> {
15571558
/// Creates a new `Rc<T>`, with the `Default` value for `T`.
@@ -1810,6 +1811,7 @@ impl<T: ?Sized> fmt::Pointer for Rc<T> {
18101811
}
18111812
}
18121813

1814+
#[cfg(not(no_global_oom_handling))]
18131815
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
18141816
impl<T> From<T> for Rc<T> {
18151817
/// Converts a generic type `T` into a `Rc<T>`

library/alloc/src/sync.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use core::iter;
1818
use core::marker::{PhantomData, Unpin, Unsize};
1919
use core::mem;
2020
use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
21+
#[cfg(not(no_global_oom_handling))]
2122
use core::pin::Pin;
2223
use core::ptr::{self, NonNull};
2324
#[cfg(not(no_global_oom_handling))]
@@ -513,6 +514,7 @@ impl<T> Arc<T> {
513514
/// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
514515
/// `data` will be pinned in memory and unable to be moved.
515516
#[inline]
517+
#[cfg(not(no_global_oom_handling))]
516518
#[stable(feature = "pin", since = "1.33.0")]
517519
pub fn pin(data: T) -> Pin<Self> {
518520
unsafe { Pin::new_unchecked(Arc::new(data)) }
@@ -2241,6 +2243,7 @@ impl<T: ?Sized> fmt::Pointer for Arc<T> {
22412243
}
22422244
}
22432245

2246+
#[cfg(not(no_global_oom_handling))]
22442247
#[stable(feature = "rust1", since = "1.0.0")]
22452248
impl<T: Default> Default for Arc<T> {
22462249
/// Creates a new `Arc<T>`, with the `Default` value for `T`.
@@ -2265,6 +2268,7 @@ impl<T: ?Sized + Hash> Hash for Arc<T> {
22652268
}
22662269
}
22672270

2271+
#[cfg(not(no_global_oom_handling))]
22682272
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
22692273
impl<T> From<T> for Arc<T> {
22702274
fn from(t: T) -> Self {

0 commit comments

Comments
 (0)