X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=library%2Falloc%2Fsrc%2Fsync.rs;h=d821e71562212ed86fd7d083331da0b78f4d6909;hb=12ed22ffe44d7b06e94c2fe0003ef96a20cf4b98;hp=742a9d7ba0187707f12c066232c0d558be9183ef;hpb=6a758ea7e48416b968955535094479dc2e7cc9e1;p=rust.git diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 742a9d7ba01..d821e715622 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -332,6 +332,7 @@ impl Arc { /// /// 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 { @@ -365,6 +366,7 @@ pub fn new(data: T) -> Arc { /// 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) -> Arc { @@ -485,11 +487,19 @@ pub fn new_zeroed() -> Arc> { /// Constructs a new `Pin>`. 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> { unsafe { Pin::new_unchecked(Arc::new(data)) } } + /// Constructs a new `Pin>`, return an error if allocation fails. + #[unstable(feature = "allocator_api", issue = "32838")] + #[inline] + pub fn try_pin(data: T) -> Result>, AllocError> { + unsafe { Ok(Pin::new_unchecked(Arc::try_new(data)?)) } + } + /// Constructs a new `Arc`, returning an error if allocation fails. /// /// # Examples @@ -2274,6 +2284,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +#[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl Default for Arc { /// Creates a new `Arc`, with the `Default` value for `T`. @@ -2298,6 +2309,7 @@ fn hash(&self, state: &mut H) { } } +#[cfg(not(no_global_oom_handling))] #[stable(feature = "from_for_ptrs", since = "1.6.0")] impl From for Arc { /// Converts a `T` into an `Arc`