@@ -346,12 +346,14 @@ fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info:
346346 let align_ptr = GEPi ( bcx, info, & [ 2 u] ) ;
347347 ( Load ( bcx, size_ptr) , Load ( bcx, align_ptr) )
348348 }
349- ty:: ty_vec( unit_ty, None ) => {
350- // The info in this case is the length of the vec, so the size is that
349+ ty:: ty_vec( _, None ) | ty:: ty_str => {
350+ let unit_ty = ty:: sequence_element_type ( bcx. tcx ( ) , t) ;
351+ // The info in this case is the length of the str, so the size is that
351352 // times the unit size.
352353 let llunit_ty = sizing_type_of ( bcx. ccx ( ) , unit_ty) ;
354+ let unit_align = llalign_of_min ( bcx. ccx ( ) , llunit_ty) ;
353355 let unit_size = llsize_of_alloc ( bcx. ccx ( ) , llunit_ty) ;
354- ( Mul ( bcx, info, C_uint ( bcx. ccx ( ) , unit_size) ) , C_uint ( bcx. ccx ( ) , 8 u ) )
356+ ( Mul ( bcx, info, C_uint ( bcx. ccx ( ) , unit_size) ) , C_uint ( bcx. ccx ( ) , unit_align ) )
355357 }
356358 _ => bcx. sess ( ) . bug ( & format ! ( "Unexpected unsized type, found {}" ,
357359 bcx. ty_to_string( t) ) [ ] )
@@ -456,8 +458,11 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
456458 & [ PointerCast ( bcx, Load ( bcx, lluniquevalue) , Type :: i8p ( bcx. ccx ( ) ) ) ] ,
457459 None ) ;
458460 bcx
459- }
460- ty:: ty_vec( ty, None ) => tvec:: make_drop_glue_unboxed ( bcx, v0, ty, false ) ,
461+ } ,
462+ ty:: ty_vec( _, None ) | ty:: ty_str => {
463+ let unit_ty = ty:: sequence_element_type ( bcx. tcx ( ) , t) ;
464+ tvec:: make_drop_glue_unboxed ( bcx, v0, unit_ty, false )
465+ } ,
461466 _ => {
462467 assert ! ( type_is_sized( bcx. tcx( ) , t) ) ;
463468 if type_needs_drop ( bcx. tcx ( ) , t) &&
0 commit comments