@@ -673,7 +673,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
673673 debug ! ( "drop_loop_pair({:?}, {:?})" , ety, ptr_based) ;
674674 let tcx = self . tcx ( ) ;
675675 let iter_ty = if ptr_based {
676- tcx. mk_ptr ( ty :: TypeAndMut { ty : ety, mutbl : hir :: Mutability :: MutMutable } )
676+ tcx. mk_mut_ptr ( ety)
677677 } else {
678678 tcx. types . usize
679679 } ;
@@ -708,15 +708,20 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
708708 let mut drop_block_stmts = vec ! [ ] ;
709709 drop_block_stmts. push ( self . assign ( & length, Rvalue :: Len ( self . lvalue . clone ( ) ) ) ) ;
710710 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 ( )
716718 ) ) ) ;
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 ( ) )
720725 ) ) ) ;
721726 } else {
722727 // index = 0 (length already pushed)
0 commit comments