Skip to content

Commit 0e7d315

Browse files
committed
Auto merge of rust-lang#120092 - zetanumbers:pin_in_static_allocator, r=Amanieu
Add `A: 'static` bound for `Arc/Rc::pin_in` Analogous to rust-lang#79327 Needed to preserve pin's [drop guarantee](https://doc.rust-lang.org/std/pin/index.html#drop-guarantee)
2 parents 476c07d + 2e4eb7e commit 0e7d315

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

alloc/src/rc.rs

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

alloc/src/sync.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -807,15 +807,21 @@ impl<T, A: Allocator> Arc<T, A> {
807807
#[cfg(not(no_global_oom_handling))]
808808
#[unstable(feature = "allocator_api", issue = "32838")]
809809
#[inline]
810-
pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>> {
810+
pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>>
811+
where
812+
A: 'static,
813+
{
811814
unsafe { Pin::new_unchecked(Arc::new_in(data, alloc)) }
812815
}
813816

814817
/// Constructs a new `Pin<Arc<T, A>>` in the provided allocator, return an error if allocation
815818
/// fails.
816819
#[inline]
817820
#[unstable(feature = "allocator_api", issue = "32838")]
818-
pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError> {
821+
pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError>
822+
where
823+
A: 'static,
824+
{
819825
unsafe { Ok(Pin::new_unchecked(Arc::try_new_in(data, alloc)?)) }
820826
}
821827

0 commit comments

Comments
 (0)