@@ -355,7 +355,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
355
355
let ty = Type :: from_ref ( llvm:: LLVMTypeOf ( dtor_addr) ) ;
356
356
ty. element_type ( ) . func_params ( )
357
357
} ;
358
- assert_eq ! ( params. len( ) , 1 ) ;
358
+ assert_eq ! ( params. len( ) , if type_is_sized ( bcx . tcx ( ) , t ) { 1 } else { 2 } ) ;
359
359
360
360
// Be sure to put the contents into a scope so we can use an invoke
361
361
// instruction to call the user destructor but still call the field
@@ -371,7 +371,12 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
371
371
372
372
let glue_type = get_drop_glue_type ( bcx. ccx ( ) , t) ;
373
373
let dtor_ty = bcx. tcx ( ) . mk_ctor_fn ( class_did, & [ glue_type] , bcx. tcx ( ) . mk_nil ( ) ) ;
374
- let ( _, bcx) = invoke ( bcx, dtor_addr, & [ v0] , dtor_ty, DebugLoc :: None ) ;
374
+ let ( _, bcx) = if type_is_sized ( bcx. tcx ( ) , t) {
375
+ invoke ( bcx, dtor_addr, & [ v0] , dtor_ty, DebugLoc :: None )
376
+ } else {
377
+ let args = [ Load ( bcx, expr:: get_dataptr ( bcx, v0) ) , Load ( bcx, expr:: get_len ( bcx, v0) ) ] ;
378
+ invoke ( bcx, dtor_addr, & args, dtor_ty, DebugLoc :: None )
379
+ } ;
375
380
376
381
bcx. fcx . pop_and_trans_custom_cleanup_scope ( bcx, contents_scope)
377
382
}
0 commit comments