Skip to content

Commit d157355

Browse files
committed
Remove A: Clone bound from Rc/Arc::assume_init.
1 parent bf1b76a commit d157355

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

library/alloc/src/rc.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,9 @@ impl<T, A: Allocator> Rc<mem::MaybeUninit<T>, A> {
11231123
/// ```
11241124
#[unstable(feature = "new_uninit", issue = "63291")]
11251125
#[inline]
1126-
pub unsafe fn assume_init(self) -> Rc<T, A>
1127-
where
1128-
A: Clone,
1129-
{
1130-
let md_self = mem::ManuallyDrop::new(self);
1131-
unsafe { Rc::from_inner_in(md_self.ptr.cast(), md_self.alloc.clone()) }
1126+
pub unsafe fn assume_init(self) -> Rc<T, A> {
1127+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1128+
unsafe { Rc::from_raw_in(ptr.cast(), alloc) }
11321129
}
11331130
}
11341131

@@ -1167,12 +1164,9 @@ impl<T, A: Allocator> Rc<[mem::MaybeUninit<T>], A> {
11671164
/// ```
11681165
#[unstable(feature = "new_uninit", issue = "63291")]
11691166
#[inline]
1170-
pub unsafe fn assume_init(self) -> Rc<[T], A>
1171-
where
1172-
A: Clone,
1173-
{
1174-
let md_self = mem::ManuallyDrop::new(self);
1175-
unsafe { Rc::from_ptr_in(md_self.ptr.as_ptr() as _, md_self.alloc.clone()) }
1167+
pub unsafe fn assume_init(self) -> Rc<[T], A> {
1168+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1169+
unsafe { Rc::from_raw_in(ptr as *const [T], alloc) }
11761170
}
11771171
}
11781172

library/alloc/src/sync.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,12 +1271,9 @@ impl<T, A: Allocator> Arc<mem::MaybeUninit<T>, A> {
12711271
#[unstable(feature = "new_uninit", issue = "63291")]
12721272
#[must_use = "`self` will be dropped if the result is not used"]
12731273
#[inline]
1274-
pub unsafe fn assume_init(self) -> Arc<T, A>
1275-
where
1276-
A: Clone,
1277-
{
1278-
let md_self = mem::ManuallyDrop::new(self);
1279-
unsafe { Arc::from_inner_in(md_self.ptr.cast(), md_self.alloc.clone()) }
1274+
pub unsafe fn assume_init(self) -> Arc<T, A> {
1275+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1276+
unsafe { Arc::from_raw_in(ptr.cast(), alloc) }
12801277
}
12811278
}
12821279

@@ -1316,12 +1313,9 @@ impl<T, A: Allocator> Arc<[mem::MaybeUninit<T>], A> {
13161313
#[unstable(feature = "new_uninit", issue = "63291")]
13171314
#[must_use = "`self` will be dropped if the result is not used"]
13181315
#[inline]
1319-
pub unsafe fn assume_init(self) -> Arc<[T], A>
1320-
where
1321-
A: Clone,
1322-
{
1323-
let md_self = mem::ManuallyDrop::new(self);
1324-
unsafe { Arc::from_ptr_in(md_self.ptr.as_ptr() as _, md_self.alloc.clone()) }
1316+
pub unsafe fn assume_init(self) -> Arc<[T], A> {
1317+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1318+
unsafe { Arc::from_raw_in(ptr as *const [T], alloc) }
13251319
}
13261320
}
13271321

0 commit comments

Comments
 (0)