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)?)) } }