Skip to content

Commit b94c1ea

Browse files
committed
Relax A: Clone bound for rc::Weak::into_raw_and_alloc
1 parent 91e6f9d commit b94c1ea

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

alloc/src/rc.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -3029,13 +3029,10 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
30293029
/// [`as_ptr`]: Weak::as_ptr
30303030
#[inline]
30313031
#[unstable(feature = "allocator_api", issue = "32838")]
3032-
pub fn into_raw_and_alloc(self) -> (*const T, A)
3033-
where
3034-
A: Clone,
3035-
{
3036-
let result = self.as_ptr();
3037-
let alloc = self.alloc.clone();
3038-
mem::forget(self);
3032+
pub fn into_raw_and_alloc(self) -> (*const T, A) {
3033+
let rc = mem::ManuallyDrop::new(self);
3034+
let result = rc.as_ptr();
3035+
let alloc = unsafe { ptr::read(&rc.alloc) };
30393036
(result, alloc)
30403037
}
30413038

0 commit comments

Comments
 (0)