@@ -557,10 +557,10 @@ where
557
557
/// if can_go then succ else drop-block
558
558
/// drop-block:
559
559
/// if ptr_based {
560
- /// ptr = &mut * cur
560
+ /// ptr = cur
561
561
/// cur = cur.offset(1)
562
562
/// } else {
563
- /// ptr = &mut P[cur]
563
+ /// ptr = &raw mut P[cur]
564
564
/// cur = cur + 1
565
565
/// }
566
566
/// drop(ptr)
@@ -574,34 +574,28 @@ where
574
574
unwind : Unwind ,
575
575
ptr_based : bool ,
576
576
) -> 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) ;
579
579
let tcx = self . tcx ( ) ;
580
580
581
- let ref_ty = tcx. mk_ref ( tcx . lifetimes . re_erased , ty:: TypeAndMut {
581
+ let ptr_ty = tcx. mk_ptr ( ty:: TypeAndMut {
582
582
ty : ety,
583
583
mutbl : hir:: Mutability :: Mutable
584
584
} ) ;
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 ) ) ;
587
587
588
588
let one = self . constant_usize ( 1 ) ;
589
589
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
+ )
599
594
} 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
+ )
605
599
} ;
606
600
607
601
let drop_block = BasicBlockData {
@@ -620,9 +614,9 @@ where
620
614
621
615
let loop_block = BasicBlockData {
622
616
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 ( ) ) ) )
626
620
] ,
627
621
is_cleanup : unwind. is_cleanup ( ) ,
628
622
terminator : Some ( Terminator {
@@ -725,8 +719,6 @@ where
725
719
726
720
let cur = self . new_temp ( iter_ty) ;
727
721
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.
730
722
Place :: from ( self . new_temp ( iter_ty) )
731
723
} else {
732
724
length. clone ( )
@@ -753,23 +745,16 @@ where
753
745
let drop_block_stmts = if ptr_based {
754
746
let tmp_ty = tcx. mk_mut_ptr ( self . place_ty ( self . place ) ) ;
755
747
let tmp = Place :: from ( self . new_temp ( tmp_ty) ) ;
756
- // tmp = &mut P;
748
+ // tmp = &raw mut P;
757
749
// cur = tmp as *mut T;
758
750
// end = Offset(cur, len);
759
751
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) ) ,
769
754
self . assign(
770
755
& 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
+ ) ,
773
758
]
774
759
} else {
775
760
// cur = 0 (length already pushed)
0 commit comments