diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 569db54b137f7..a320a244abd78 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -884,7 +884,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 6ae52cc7827bd..297a273d274bf 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -807,7 +807,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)) } } @@ -815,7 +818,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)?)) } }