mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieu
Add `A: 'static` bound for `Arc/Rc::pin_in` Analogous to https://github.com/rust-lang/rust/pull/79327 Needed to preserve pin's [drop guarantee](https://doc.rust-lang.org/std/pin/index.html#drop-guarantee)
This commit is contained in:
commit
46961d2407
@ -884,7 +884,10 @@ impl<T, A: Allocator> Rc<T, A> {
|
|||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn pin_in(value: T, alloc: A) -> Pin<Self> {
|
pub fn pin_in(value: T, alloc: A) -> Pin<Self>
|
||||||
|
where
|
||||||
|
A: 'static,
|
||||||
|
{
|
||||||
unsafe { Pin::new_unchecked(Rc::new_in(value, alloc)) }
|
unsafe { Pin::new_unchecked(Rc::new_in(value, alloc)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +807,10 @@ impl<T, A: Allocator> Arc<T, A> {
|
|||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>> {
|
pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>>
|
||||||
|
where
|
||||||
|
A: 'static,
|
||||||
|
{
|
||||||
unsafe { Pin::new_unchecked(Arc::new_in(data, alloc)) }
|
unsafe { Pin::new_unchecked(Arc::new_in(data, alloc)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +818,10 @@ impl<T, A: Allocator> Arc<T, A> {
|
|||||||
/// fails.
|
/// fails.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||||
pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError> {
|
pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError>
|
||||||
|
where
|
||||||
|
A: 'static,
|
||||||
|
{
|
||||||
unsafe { Ok(Pin::new_unchecked(Arc::try_new_in(data, alloc)?)) }
|
unsafe { Ok(Pin::new_unchecked(Arc::try_new_in(data, alloc)?)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user