From 656a38830b5228d5a47222c8f3da2a8346ccab0b Mon Sep 17 00:00:00 2001 From: zetanumbers Date: Thu, 18 Jan 2024 14:28:39 +0300 Subject: [PATCH] Add `A: 'static` bound for `Arc/Rc::pin_in` --- library/alloc/src/rc.rs | 5 ++++- library/alloc/src/sync.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 263b1449de156..a32a0271adfe7 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -883,7 +883,10 @@ impl Rc { #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] #[inline] - pub fn pin_in(value: T, alloc: A) -> Pin { + pub fn pin_in(value: T, alloc: A) -> Pin + where + A: 'static, + { unsafe { Pin::new_unchecked(Rc::new_in(value, alloc)) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 5273b3cb2dafa..c389066e6b62e 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -801,7 +801,10 @@ impl Arc { #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] #[inline] - pub fn pin_in(data: T, alloc: A) -> Pin> { + pub fn pin_in(data: T, alloc: A) -> Pin> + where + A: 'static, + { unsafe { Pin::new_unchecked(Arc::new_in(data, alloc)) } } @@ -809,7 +812,10 @@ impl Arc { /// fails. #[inline] #[unstable(feature = "allocator_api", issue = "32838")] - pub fn try_pin_in(data: T, alloc: A) -> Result>, AllocError> { + pub fn try_pin_in(data: T, alloc: A) -> Result>, AllocError> + where + A: 'static, + { unsafe { Ok(Pin::new_unchecked(Arc::try_new_in(data, alloc)?)) } }