diff options
| author | bors <bors@rust-lang.org> | 2021-07-03 13:23:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-03 13:23:28 +0000 |
| commit | 8649737beefccbef2d6bc0113df4650dd05ad7f2 (patch) | |
| tree | 9cbcefba65969821b5d2de4c428727bcd7b60872 /library/alloc/src/sync.rs | |
| parent | a8b8558f083d86247ef3260ebb4f97b276cdbf73 (diff) | |
| parent | 7775dffbc052f66ef80cad3c5ddc4f7e71585959 (diff) | |
| download | rust-8649737beefccbef2d6bc0113df4650dd05ad7f2.tar.gz rust-8649737beefccbef2d6bc0113df4650dd05ad7f2.zip | |
Auto merge of #86810 - ojeda:alloc-gate, r=dtolnay
alloc: `no_global_oom_handling`: disable `new()`s, `pin()`s, etc. They are infallible, and could not be actually used because they will trigger an error when monomorphized, but it is better to just remove them. Link: https://github.com/Rust-for-Linux/linux/pull/402 Suggested-by: Gary Guo <gary@garyguo.net> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'library/alloc/src/sync.rs')
| -rw-r--r-- | library/alloc/src/sync.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 742a9d7ba01..4b34a7dc894 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -19,6 +19,7 @@ use core::marker::{PhantomData, Unpin, Unsize}; use core::mem::size_of_val; use core::mem::{self, align_of_val_raw}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; +#[cfg(not(no_global_oom_handling))] use core::pin::Pin; use core::ptr::{self, NonNull}; #[cfg(not(no_global_oom_handling))] @@ -332,6 +333,7 @@ impl<T> Arc<T> { /// /// let five = Arc::new(5); /// ``` + #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn new(data: T) -> Arc<T> { @@ -365,6 +367,7 @@ impl<T> Arc<T> { /// me: me.clone(), /// }); /// ``` + #[cfg(not(no_global_oom_handling))] #[inline] #[unstable(feature = "arc_new_cyclic", issue = "75861")] pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> T) -> Arc<T> { @@ -485,6 +488,7 @@ impl<T> Arc<T> { /// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then /// `data` will be pinned in memory and unable to be moved. + #[cfg(not(no_global_oom_handling))] #[stable(feature = "pin", since = "1.33.0")] pub fn pin(data: T) -> Pin<Arc<T>> { unsafe { Pin::new_unchecked(Arc::new(data)) } @@ -2274,6 +2278,7 @@ impl<T: ?Sized> fmt::Pointer for Arc<T> { } } +#[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl<T: Default> Default for Arc<T> { /// Creates a new `Arc<T>`, with the `Default` value for `T`. @@ -2298,6 +2303,7 @@ impl<T: ?Sized + Hash> Hash for Arc<T> { } } +#[cfg(not(no_global_oom_handling))] #[stable(feature = "from_for_ptrs", since = "1.6.0")] impl<T> From<T> for Arc<T> { /// Converts a `T` into an `Arc<T>` |
