@@ -242,10 +242,28 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
242242 let lvalue = self . trans_lvalue ( & bcx, location) ;
243243 let drop_fn = glue:: get_drop_glue ( bcx. ccx ( ) , ty) ;
244244 let drop_ty = glue:: get_drop_glue_type ( bcx. tcx ( ) , ty) ;
245- let llvalue = if drop_ty != ty {
246- bcx. pointercast ( lvalue. llval , type_of:: type_of ( bcx. ccx ( ) , drop_ty) . ptr_to ( ) )
245+ let is_sized = common:: type_is_sized ( bcx. tcx ( ) , ty) ;
246+ let llvalue = if is_sized {
247+ if drop_ty != ty {
248+ bcx. pointercast ( lvalue. llval , type_of:: type_of ( bcx. ccx ( ) , drop_ty) . ptr_to ( ) )
249+ } else {
250+ lvalue. llval
251+ }
247252 } else {
248- lvalue. llval
253+ // FIXME(#36457) Currently drop glue takes sized
254+ // values as a `*(data, meta)`, but elsewhere in
255+ // MIR we pass `(data, meta)` as two separate
256+ // arguments. It would be better to fix drop glue,
257+ // but I am shooting for a quick fix to #35546
258+ // here that can be cleanly backported to beta, so
259+ // I want to avoid touching all of trans.
260+ bcx. with_block ( |bcx| {
261+ let scratch = base:: alloc_ty ( bcx, ty, "drop" ) ;
262+ base:: call_lifetime_start ( bcx, scratch) ;
263+ build:: Store ( bcx, lvalue. llval , base:: get_dataptr ( bcx, scratch) ) ;
264+ build:: Store ( bcx, lvalue. llextra , base:: get_meta ( bcx, scratch) ) ;
265+ scratch
266+ } )
249267 } ;
250268 if let Some ( unwind) = unwind {
251269 bcx. invoke ( drop_fn,
0 commit comments