@@ -557,10 +557,10 @@ where
557557 /// if can_go then succ else drop-block
558558 /// drop-block:
559559 /// if ptr_based {
560- /// ptr = &mut * cur
560+ /// ptr = cur
561561 /// cur = cur.offset(1)
562562 /// } else {
563- /// ptr = &mut P[cur]
563+ /// ptr = &raw mut P[cur]
564564 /// cur = cur + 1
565565 /// }
566566 /// drop(ptr)
@@ -574,34 +574,28 @@ where
574574 unwind : Unwind ,
575575 ptr_based : bool ,
576576 ) -> BasicBlock {
577- let copy = |place : & Place < ' tcx > | Operand :: Copy ( place. clone ( ) ) ;
578- let move_ = |place : & Place < ' tcx > | Operand :: Move ( place. clone ( ) ) ;
577+ let copy = |place : Place < ' tcx > | Operand :: Copy ( place) ;
578+ let move_ = |place : Place < ' tcx > | Operand :: Move ( place) ;
579579 let tcx = self . tcx ( ) ;
580580
581- let ref_ty = tcx. mk_ref ( tcx . lifetimes . re_erased , ty:: TypeAndMut {
581+ let ptr_ty = tcx. mk_ptr ( ty:: TypeAndMut {
582582 ty : ety,
583583 mutbl : hir:: Mutability :: Mutable
584584 } ) ;
585- let ptr = & Place :: from ( self . new_temp ( ref_ty ) ) ;
586- let can_go = & Place :: from ( self . new_temp ( tcx. types . bool ) ) ;
585+ let ptr = & Place :: from ( self . new_temp ( ptr_ty ) ) ;
586+ let can_go = Place :: from ( self . new_temp ( tcx. types . bool ) ) ;
587587
588588 let one = self . constant_usize ( 1 ) ;
589589 let ( ptr_next, cur_next) = if ptr_based {
590- ( Rvalue :: Ref (
591- tcx. lifetimes . re_erased ,
592- BorrowKind :: Mut { allow_two_phase_borrow : false } ,
593- Place {
594- base : PlaceBase :: Local ( cur) ,
595- projection : tcx. intern_place_elems ( & vec ! [ ProjectionElem :: Deref ] ) ,
596- }
597- ) ,
598- Rvalue :: BinaryOp ( BinOp :: Offset , move_ ( & Place :: from ( cur) ) , one) )
590+ (
591+ Rvalue :: Use ( copy ( cur. into ( ) ) ) ,
592+ Rvalue :: BinaryOp ( BinOp :: Offset , move_ ( cur. into ( ) ) , one) ,
593+ )
599594 } else {
600- ( Rvalue :: Ref (
601- tcx. lifetimes . re_erased ,
602- BorrowKind :: Mut { allow_two_phase_borrow : false } ,
603- tcx. mk_place_index ( self . place . clone ( ) , cur) ) ,
604- Rvalue :: BinaryOp ( BinOp :: Add , move_ ( & Place :: from ( cur) ) , one) )
595+ (
596+ Rvalue :: AddressOf ( Mutability :: Mut , tcx. mk_place_index ( self . place . clone ( ) , cur) ) ,
597+ Rvalue :: BinaryOp ( BinOp :: Add , move_ ( cur. into ( ) ) , one) ,
598+ )
605599 } ;
606600
607601 let drop_block = BasicBlockData {
@@ -620,9 +614,9 @@ where
620614
621615 let loop_block = BasicBlockData {
622616 statements : vec ! [
623- self . assign( can_go, Rvalue :: BinaryOp ( BinOp :: Eq ,
624- copy( & Place :: from( cur) ) ,
625- copy( length_or_end) ) )
617+ self . assign( & can_go, Rvalue :: BinaryOp ( BinOp :: Eq ,
618+ copy( Place :: from( cur) ) ,
619+ copy( length_or_end. clone ( ) ) ) )
626620 ] ,
627621 is_cleanup : unwind. is_cleanup ( ) ,
628622 terminator : Some ( Terminator {
@@ -725,8 +719,6 @@ where
725719
726720 let cur = self . new_temp ( iter_ty) ;
727721 let length_or_end = if ptr_based {
728- // FIXME check if we want to make it return a `Place` directly
729- // if all use sites want a `Place::Base` anyway.
730722 Place :: from ( self . new_temp ( iter_ty) )
731723 } else {
732724 length. clone ( )
@@ -753,23 +745,16 @@ where
753745 let drop_block_stmts = if ptr_based {
754746 let tmp_ty = tcx. mk_mut_ptr ( self . place_ty ( self . place ) ) ;
755747 let tmp = Place :: from ( self . new_temp ( tmp_ty) ) ;
756- // tmp = &mut P;
748+ // tmp = &raw mut P;
757749 // cur = tmp as *mut T;
758750 // end = Offset(cur, len);
759751 vec ! [
760- self . assign( & tmp, Rvalue :: Ref (
761- tcx. lifetimes. re_erased,
762- BorrowKind :: Mut { allow_two_phase_borrow: false } ,
763- self . place. clone( )
764- ) ) ,
765- self . assign(
766- & cur,
767- Rvalue :: Cast ( CastKind :: Misc , Operand :: Move ( tmp) , iter_ty) ,
768- ) ,
752+ self . assign( & tmp, Rvalue :: AddressOf ( Mutability :: Mut , self . place. clone( ) ) ) ,
753+ self . assign( & cur, Rvalue :: Cast ( CastKind :: Misc , Operand :: Move ( tmp) , iter_ty) ) ,
769754 self . assign(
770755 & length_or_end,
771- Rvalue :: BinaryOp ( BinOp :: Offset , Operand :: Copy ( cur) , Operand :: Move ( length)
772- ) ) ,
756+ Rvalue :: BinaryOp ( BinOp :: Offset , Operand :: Copy ( cur) , Operand :: Move ( length) ) ,
757+ ) ,
773758 ]
774759 } else {
775760 // cur = 0 (length already pushed)
0 commit comments