Skip to content

Commit c13f158

Browse files
committed
Add A: 'static to Rc::pin_in and Arc::pin_in
This is required for soundness since `Pin` requires the memory to be leaked if the `Pin` is leaked.
1 parent 0187bd8 commit c13f158

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: library/alloc/src/rc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,10 @@ impl<T, A: Allocator> Rc<T, A> {
883883
#[cfg(not(no_global_oom_handling))]
884884
#[unstable(feature = "allocator_api", issue = "32838")]
885885
#[inline]
886-
pub fn pin_in(value: T, alloc: A) -> Pin<Self> {
886+
pub fn pin_in(value: T, alloc: A) -> Pin<Self>
887+
where
888+
A: 'static,
889+
{
887890
unsafe { Pin::new_unchecked(Rc::new_in(value, alloc)) }
888891
}
889892

Diff for: library/alloc/src/sync.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,10 @@ impl<T, A: Allocator> Arc<T, A> {
801801
#[cfg(not(no_global_oom_handling))]
802802
#[unstable(feature = "allocator_api", issue = "32838")]
803803
#[inline]
804-
pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>> {
804+
pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>>
805+
where
806+
A: 'static,
807+
{
805808
unsafe { Pin::new_unchecked(Arc::new_in(data, alloc)) }
806809
}
807810

0 commit comments

Comments
 (0)