@@ -774,16 +774,13 @@ mod tests {
774774 // SAFETY: borrowed_ptr points to a valid String within the Rc
775775 assert_eq ! ( unsafe { borrowed_ptr. get:: <String >( ) } , "example" ) ;
776776
777- // Get the function pointer for dropping the Rc
778- let drop_fn = rc_shape
779- . vtable
780- . drop_in_place ( )
781- . expect ( "Rc<T> should have drop_in_place" ) ;
782-
783777 // Drop the Rc in place
784778 // SAFETY: rc_ptr points to a valid Rc<String>
785- let rc_ox = OxMut :: new ( rc_ptr, rc_shape) ;
786- unsafe { drop_fn ( rc_ox) } ;
779+ unsafe {
780+ rc_shape
781+ . call_drop_in_place ( rc_ptr)
782+ . expect ( "Rc<T> should have drop_in_place" ) ;
783+ }
787784
788785 // Deallocate the memory
789786 // SAFETY: rc_ptr was allocated by rc_shape and is now dropped (but memory is still valid)
@@ -821,14 +818,14 @@ mod tests {
821818 let weak1_uninit_ptr = weak_shape. allocate ( ) . unwrap ( ) ;
822819 let downgrade_into_fn = rc_def. vtable . downgrade_into_fn . unwrap ( ) ;
823820 // SAFETY: rc1_ptr points to a valid Rc, weak1_uninit_ptr is allocated for a Weak
824- let weak1_ptr = unsafe { downgrade_into_fn ( rc1_ptr. as_const ( ) , weak1_uninit_ptr) } ;
821+ let weak1_ptr = unsafe { downgrade_into_fn ( rc1_ptr, weak1_uninit_ptr) } ;
825822
826823 // 3. Upgrade weak1 to create a second Rc (rc2)
827824 let rc2_uninit_ptr = rc_shape. allocate ( ) . unwrap ( ) ;
828825 let upgrade_into_fn = weak_def. vtable . upgrade_into_fn . unwrap ( ) ;
829826 // SAFETY: weak1_ptr points to a valid Weak, rc2_uninit_ptr is allocated for an Rc.
830827 // Upgrade should succeed as rc1 still exists.
831- let rc2_ptr = unsafe { upgrade_into_fn ( weak1_ptr. as_const ( ) , rc2_uninit_ptr) }
828+ let rc2_ptr = unsafe { upgrade_into_fn ( weak1_ptr, rc2_uninit_ptr) }
832829 . expect ( "Upgrade should succeed while original Rc exists" ) ;
833830
834831 // Check the content of the upgraded Rc
@@ -839,22 +836,16 @@ mod tests {
839836 assert_eq ! ( unsafe { borrowed_ptr. get:: <String >( ) } , "example" ) ;
840837
841838 // 4. Drop everything and free memory
842- let rc_drop_fn = rc_shape. vtable . drop_in_place ( ) . unwrap ( ) ;
843- let weak_drop_fn = weak_shape. vtable . drop_in_place ( ) . unwrap ( ) ;
844-
845839 unsafe {
846840 // Drop Rcs
847- let rc1_ox = OxMut :: new ( rc1_ptr, rc_shape) ;
848- rc_drop_fn ( rc1_ox) ;
841+ rc_shape. call_drop_in_place ( rc1_ptr) . unwrap ( ) ;
849842 rc_shape. deallocate_mut ( rc1_ptr) . unwrap ( ) ;
850843
851- let rc2_ox = OxMut :: new ( rc2_ptr, rc_shape) ;
852- rc_drop_fn ( rc2_ox) ;
844+ rc_shape. call_drop_in_place ( rc2_ptr) . unwrap ( ) ;
853845 rc_shape. deallocate_mut ( rc2_ptr) . unwrap ( ) ;
854846
855847 // Drop Weak
856- let weak1_ox = OxMut :: new ( weak1_ptr, weak_shape) ;
857- weak_drop_fn ( weak1_ox) ;
848+ weak_shape. call_drop_in_place ( weak1_ptr) . unwrap ( ) ;
858849 weak_shape. deallocate_mut ( weak1_ptr) . unwrap ( ) ;
859850 }
860851 }
@@ -890,21 +881,19 @@ mod tests {
890881 let weak1_uninit_ptr = weak_shape. allocate ( ) . unwrap ( ) ;
891882 let downgrade_into_fn = rc_def. vtable . downgrade_into_fn . unwrap ( ) ;
892883 // SAFETY: rc1_ptr is valid, weak1_uninit_ptr is allocated for Weak
893- let weak1_ptr = unsafe { downgrade_into_fn ( rc1_ptr. as_const ( ) , weak1_uninit_ptr) } ;
884+ let weak1_ptr = unsafe { downgrade_into_fn ( rc1_ptr, weak1_uninit_ptr) } ;
894885
895886 // 3. Drop and free the strong pointer (rc1)
896- let rc_drop_fn = rc_shape. vtable . drop_in_place ( ) . unwrap ( ) ;
897887 unsafe {
898- let rc1_ox = OxMut :: new ( rc1_ptr, rc_shape) ;
899- rc_drop_fn ( rc1_ox) ;
888+ rc_shape. call_drop_in_place ( rc1_ptr) . unwrap ( ) ;
900889 rc_shape. deallocate_mut ( rc1_ptr) . unwrap ( ) ;
901890 }
902891
903892 // 4. Attempt to upgrade the weak pointer (weak1)
904893 let upgrade_into_fn = weak_def. vtable . upgrade_into_fn . unwrap ( ) ;
905894 let rc2_uninit_ptr = rc_shape. allocate ( ) . unwrap ( ) ;
906895 // SAFETY: weak1_ptr is valid (though points to dropped data), rc2_uninit_ptr is allocated for Rc
907- let upgrade_result = unsafe { upgrade_into_fn ( weak1_ptr. as_const ( ) , rc2_uninit_ptr) } ;
896+ let upgrade_result = unsafe { upgrade_into_fn ( weak1_ptr, rc2_uninit_ptr) } ;
908897
909898 // Assert that the upgrade failed
910899 assert ! (
@@ -913,14 +902,12 @@ mod tests {
913902 ) ;
914903
915904 // 5. Clean up: Deallocate the memory intended for the failed upgrade and drop/deallocate the weak pointer
916- let weak_drop_fn = weak_shape. vtable . drop_in_place ( ) . unwrap ( ) ;
917905 unsafe {
918906 // Deallocate the *uninitialized* memory allocated for the failed upgrade attempt
919907 rc_shape. deallocate_uninit ( rc2_uninit_ptr) . unwrap ( ) ;
920908
921909 // Drop and deallocate the weak pointer
922- let weak1_ox = OxMut :: new ( weak1_ptr, weak_shape) ;
923- weak_drop_fn ( weak1_ox) ;
910+ weak_shape. call_drop_in_place ( weak1_ptr) . unwrap ( ) ;
924911 weak_shape. deallocate_mut ( weak1_ptr) . unwrap ( ) ;
925912 }
926913 }
0 commit comments