diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 263b1449de156..f5a70504d1f3e 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1910,7 +1910,10 @@ impl Rc { } #[cfg(not(no_global_oom_handling))] - fn from_box_in(src: Box) -> Rc { + fn from_box_in(src: Box) -> Rc + where + A: Clone, + { unsafe { let value_size = size_of_val(&*src); let ptr = Self::allocate_for_ptr_in(&*src, Box::allocator(&src)); @@ -1924,7 +1927,7 @@ impl Rc { // Free the allocation without dropping its contents let (bptr, alloc) = Box::into_raw_with_allocator(src); - let src = Box::from_raw(bptr as *mut mem::ManuallyDrop); + let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop, alloc.clone()); drop(src); Self::from_ptr_in(ptr, alloc)