@@ -673,7 +673,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
673
673
debug ! ( "drop_loop_pair({:?}, {:?})" , ety, ptr_based) ;
674
674
let tcx = self . tcx ( ) ;
675
675
let iter_ty = if ptr_based {
676
- tcx. mk_ptr ( ty :: TypeAndMut { ty : ety, mutbl : hir :: Mutability :: MutMutable } )
676
+ tcx. mk_mut_ptr ( ety)
677
677
} else {
678
678
tcx. types . usize
679
679
} ;
@@ -708,15 +708,20 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
708
708
let mut drop_block_stmts = vec ! [ ] ;
709
709
drop_block_stmts. push ( self . assign ( & length, Rvalue :: Len ( self . lvalue . clone ( ) ) ) ) ;
710
710
if ptr_based {
711
- // cur = &LV[0];
712
- // end = &LV[len];
713
- drop_block_stmts. push ( self . assign ( & cur, Rvalue :: Ref (
714
- tcx. types . re_erased , BorrowKind :: Mut ,
715
- self . lvalue . clone ( ) . index ( zero. clone ( ) )
711
+ let tmp_ty = tcx. mk_mut_ptr ( self . lvalue_ty ( self . lvalue ) ) ;
712
+ let tmp = Lvalue :: Local ( self . new_temp ( tmp_ty) ) ;
713
+ // tmp = &LV;
714
+ // cur = tmp as *mut T;
715
+ // end = Offset(cur, len);
716
+ drop_block_stmts. push ( self . assign ( & tmp, Rvalue :: Ref (
717
+ tcx. types . re_erased , BorrowKind :: Mut , self . lvalue . clone ( )
716
718
) ) ) ;
717
- drop_block_stmts. push ( self . assign ( & length_or_end, Rvalue :: Ref (
718
- tcx. types . re_erased , BorrowKind :: Mut ,
719
- self . lvalue . clone ( ) . index ( Operand :: Consume ( length. clone ( ) ) )
719
+ drop_block_stmts. push ( self . assign ( & cur, Rvalue :: Cast (
720
+ CastKind :: Misc , Operand :: Consume ( tmp. clone ( ) ) , iter_ty
721
+ ) ) ) ;
722
+ drop_block_stmts. push ( self . assign ( & length_or_end,
723
+ Rvalue :: BinaryOp ( BinOp :: Offset ,
724
+ Operand :: Consume ( cur. clone ( ) ) , Operand :: Consume ( length. clone ( ) )
720
725
) ) ) ;
721
726
} else {
722
727
// index = 0 (length already pushed)
0 commit comments