@@ -9,7 +9,7 @@ use rustc::mir::{
99 self , AggregateKind , BindingForm , BorrowKind , ClearCrossCrate , Constant ,
1010 ConstraintCategory , Field , Local , LocalDecl , LocalKind , Location , Operand ,
1111 Place , PlaceProjection , ProjectionElem , Rvalue , Statement , StatementKind ,
12- TerminatorKind , VarBindingForm , NeoPlace , NeoPlaceTree , PlaceBase ,
12+ TerminatorKind , VarBindingForm , NeoPlace , PlaceBase ,
1313} ;
1414use rustc:: mir:: tcx:: PlaceTy ;
1515use rustc:: ty:: { self , DefIdTree } ;
@@ -1611,16 +1611,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16111611 including_downcast : & IncludingDowncast ,
16121612 ) -> Result < ( ) , ( ) > {
16131613 match place. clone ( ) . into_tree ( ) {
1614- NeoPlaceTree :: Base ( PlaceBase :: Promoted ( _) ) => {
1614+ Place :: Promoted ( _) => {
16151615 buf. push_str ( "promoted" ) ;
16161616 }
1617- NeoPlaceTree :: Base ( PlaceBase :: Local ( local) ) => {
1617+ Place :: Local ( local) => {
16181618 self . append_local_to_string ( local, buf) ?;
16191619 }
1620- NeoPlaceTree :: Base ( PlaceBase :: Static ( ref static_) ) => {
1620+ Place :: Static ( ref static_) => {
16211621 buf. push_str ( & self . infcx . tcx . item_name ( static_. def_id ) . to_string ( ) ) ;
16221622 }
1623- NeoPlaceTree :: Projected ( proj) => {
1623+ Place :: Projection ( proj) => {
16241624 match proj. elem {
16251625 ProjectionElem :: Deref => {
16261626 let upvar_field_projection =
@@ -1634,27 +1634,29 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16341634 buf. push_str ( & format ! ( "*{}" , & name) ) ;
16351635 }
16361636 } else {
1637+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1638+
16371639 if autoderef {
16381640 self . append_place_to_string (
1639- & proj . base ,
1641+ & neo_place ,
16401642 buf,
16411643 autoderef,
16421644 & including_downcast,
16431645 ) ?;
1644- } else if let Some ( local) = proj . base . as_local ( ) {
1646+ } else if let Some ( local) = neo_place . as_local ( ) {
16451647 if let Some ( ClearCrossCrate :: Set ( BindingForm :: RefForGuard ) ) =
16461648 self . mir . local_decls [ local] . is_user_variable
16471649 {
16481650 self . append_place_to_string (
1649- & proj . base ,
1651+ & neo_place ,
16501652 buf,
16511653 autoderef,
16521654 & including_downcast,
16531655 ) ?;
16541656 } else {
16551657 buf. push_str ( & "*" ) ;
16561658 self . append_place_to_string (
1657- & proj . base ,
1659+ & neo_place ,
16581660 buf,
16591661 autoderef,
16601662 & including_downcast,
@@ -1663,7 +1665,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16631665 } else {
16641666 buf. push_str ( & "*" ) ;
16651667 self . append_place_to_string (
1666- & proj . base ,
1668+ & neo_place ,
16671669 buf,
16681670 autoderef,
16691671 & including_downcast,
@@ -1672,8 +1674,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16721674 }
16731675 }
16741676 ProjectionElem :: Downcast ( ..) => {
1677+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
16751678 self . append_place_to_string (
1676- & proj . base ,
1679+ & neo_place ,
16771680 buf,
16781681 autoderef,
16791682 & including_downcast,
@@ -1691,9 +1694,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16911694 let name = self . mir . upvar_decls [ var_index] . debug_name . to_string ( ) ;
16921695 buf. push_str ( & name) ;
16931696 } else {
1694- let field_name = self . describe_field ( & proj. base , field) ;
1697+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1698+ let field_name = self . describe_field ( & neo_place, field) ;
16951699 self . append_place_to_string (
1696- & proj . base ,
1700+ & neo_place ,
16971701 buf,
16981702 autoderef,
16991703 & including_downcast,
@@ -1704,8 +1708,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17041708 ProjectionElem :: Index ( index) => {
17051709 autoderef = true ;
17061710
1711+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
17071712 self . append_place_to_string (
1708- & proj . base ,
1713+ & neo_place ,
17091714 buf,
17101715 autoderef,
17111716 & including_downcast,
@@ -1718,11 +1723,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17181723 }
17191724 ProjectionElem :: ConstantIndex { .. } | ProjectionElem :: Subslice { .. } => {
17201725 autoderef = true ;
1726+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
17211727 // Since it isn't possible to borrow an element on a particular index and
17221728 // then use another while the borrow is held, don't output indices details
17231729 // to avoid confusing the end-user
17241730 self . append_place_to_string (
1725- & proj . base ,
1731+ & neo_place ,
17261732 buf,
17271733 autoderef,
17281734 & including_downcast,
@@ -1752,16 +1758,19 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17521758 /// End-user visible description of the `field`nth field of `base`
17531759 fn describe_field ( & self , base : & NeoPlace < ' tcx > , field : Field ) -> String {
17541760 match base. clone ( ) . into_tree ( ) {
1755- NeoPlaceTree :: Base ( PlaceBase :: Local ( local) ) => {
1761+ Place :: Local ( local) => {
17561762 let local = & self . mir . local_decls [ local] ;
17571763 self . describe_field_from_ty ( & local. ty , field)
17581764 }
1759- NeoPlaceTree :: Base ( PlaceBase :: Promoted ( ref prom) ) =>
1765+ Place :: Promoted ( ref prom) =>
17601766 self . describe_field_from_ty ( & prom. 1 , field) ,
1761- NeoPlaceTree :: Base ( PlaceBase :: Static ( ref static_) ) =>
1767+ Place :: Static ( ref static_) =>
17621768 self . describe_field_from_ty ( & static_. ty , field) ,
1763- NeoPlaceTree :: Projected ( ref proj) => match proj. elem {
1764- ProjectionElem :: Deref => self . describe_field ( & proj. base , field) ,
1769+ Place :: Projection ( ref proj) => match proj. elem {
1770+ ProjectionElem :: Deref => {
1771+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1772+ self . describe_field ( & neo_place, field)
1773+ }
17651774 ProjectionElem :: Downcast ( def, variant_index) =>
17661775 def. variants [ variant_index] . fields [ field. index ( ) ] . ident . to_string ( ) ,
17671776 ProjectionElem :: Field ( _, field_type) => {
@@ -1770,7 +1779,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17701779 ProjectionElem :: Index ( ..)
17711780 | ProjectionElem :: ConstantIndex { .. }
17721781 | ProjectionElem :: Subslice { .. } => {
1773- self . describe_field ( & proj. base , field)
1782+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1783+ self . describe_field ( & neo_place, field)
17741784 }
17751785 } ,
17761786 }
0 commit comments