@@ -747,6 +747,7 @@ where
747
747
) -> BasicBlock {
748
748
debug ! ( "open_drop_for_array({:?}, {:?})" , element_ty, opt_size) ;
749
749
let tcx = self . tcx ( ) ;
750
+ let span = self . source_info . span ;
750
751
751
752
if let Some ( 0 ) = opt_size {
752
753
span_bug ! ( self . source_info. span, "Opened drop for zero-length array of {element_ty:?}" )
@@ -758,6 +759,9 @@ where
758
759
let slice_ptr_ty = Ty :: new_mut_ptr ( tcx, slice_ty) ;
759
760
let slice_ptr = self . new_temp ( slice_ptr_ty) ;
760
761
762
+ let drop_in_place = tcx. require_lang_item ( LangItem :: DropInPlace , Some ( span) ) ;
763
+ let slice_drop_in_place = Operand :: function_handle ( tcx, drop_in_place, [ slice_ty. into ( ) ] , span) ;
764
+
761
765
let unsize_and_drop_block = BasicBlockData {
762
766
statements : vec ! [
763
767
self . assign( Place :: from( array_ptr) , Rvalue :: RawPtr ( Mutability :: Mut , self . place) ) ,
@@ -776,11 +780,19 @@ where
776
780
is_cleanup : self . unwind . is_cleanup ( ) ,
777
781
terminator : Some ( Terminator {
778
782
source_info : self . source_info ,
779
- kind : TerminatorKind :: Drop {
780
- place : Place :: from ( slice_ptr) . project_deeper ( & [ PlaceElem :: Deref ] , tcx) ,
781
- target : self . succ ,
783
+ kind : TerminatorKind :: Call {
784
+ func : slice_drop_in_place,
785
+ args : Box :: new ( [
786
+ Spanned {
787
+ node : Operand :: Move ( Place :: from ( slice_ptr) ) ,
788
+ span,
789
+ }
790
+ ] ) ,
791
+ destination : Place :: from ( self . new_temp ( tcx. types . unit ) ) ,
792
+ target : Some ( self . succ ) ,
782
793
unwind : self . unwind . into_action ( ) ,
783
- replace : false ,
794
+ call_source : CallSource :: Misc ,
795
+ fn_span : span,
784
796
} ,
785
797
} ) ,
786
798
} ;
0 commit comments