@@ -9,7 +9,7 @@ use rustc::mir::{
9
9
self , AggregateKind , BindingForm , BorrowKind , ClearCrossCrate , Constant ,
10
10
ConstraintCategory , Field , Local , LocalDecl , LocalKind , Location , Operand ,
11
11
Place , PlaceProjection , ProjectionElem , Rvalue , Statement , StatementKind ,
12
- TerminatorKind , VarBindingForm , NeoPlace , NeoPlaceTree , PlaceBase ,
12
+ TerminatorKind , VarBindingForm , NeoPlace , PlaceBase ,
13
13
} ;
14
14
use rustc:: mir:: tcx:: PlaceTy ;
15
15
use rustc:: ty:: { self , DefIdTree } ;
@@ -1611,16 +1611,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1611
1611
including_downcast : & IncludingDowncast ,
1612
1612
) -> Result < ( ) , ( ) > {
1613
1613
match place. clone ( ) . into_tree ( ) {
1614
- NeoPlaceTree :: Base ( PlaceBase :: Promoted ( _) ) => {
1614
+ Place :: Promoted ( _) => {
1615
1615
buf. push_str ( "promoted" ) ;
1616
1616
}
1617
- NeoPlaceTree :: Base ( PlaceBase :: Local ( local) ) => {
1617
+ Place :: Local ( local) => {
1618
1618
self . append_local_to_string ( local, buf) ?;
1619
1619
}
1620
- NeoPlaceTree :: Base ( PlaceBase :: Static ( ref static_) ) => {
1620
+ Place :: Static ( ref static_) => {
1621
1621
buf. push_str ( & self . infcx . tcx . item_name ( static_. def_id ) . to_string ( ) ) ;
1622
1622
}
1623
- NeoPlaceTree :: Projected ( proj) => {
1623
+ Place :: Projection ( proj) => {
1624
1624
match proj. elem {
1625
1625
ProjectionElem :: Deref => {
1626
1626
let upvar_field_projection =
@@ -1634,27 +1634,29 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1634
1634
buf. push_str ( & format ! ( "*{}" , & name) ) ;
1635
1635
}
1636
1636
} else {
1637
+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1638
+
1637
1639
if autoderef {
1638
1640
self . append_place_to_string (
1639
- & proj . base ,
1641
+ & neo_place ,
1640
1642
buf,
1641
1643
autoderef,
1642
1644
& including_downcast,
1643
1645
) ?;
1644
- } else if let Some ( local) = proj . base . as_local ( ) {
1646
+ } else if let Some ( local) = neo_place . as_local ( ) {
1645
1647
if let Some ( ClearCrossCrate :: Set ( BindingForm :: RefForGuard ) ) =
1646
1648
self . mir . local_decls [ local] . is_user_variable
1647
1649
{
1648
1650
self . append_place_to_string (
1649
- & proj . base ,
1651
+ & neo_place ,
1650
1652
buf,
1651
1653
autoderef,
1652
1654
& including_downcast,
1653
1655
) ?;
1654
1656
} else {
1655
1657
buf. push_str ( & "*" ) ;
1656
1658
self . append_place_to_string (
1657
- & proj . base ,
1659
+ & neo_place ,
1658
1660
buf,
1659
1661
autoderef,
1660
1662
& including_downcast,
@@ -1663,7 +1665,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1663
1665
} else {
1664
1666
buf. push_str ( & "*" ) ;
1665
1667
self . append_place_to_string (
1666
- & proj . base ,
1668
+ & neo_place ,
1667
1669
buf,
1668
1670
autoderef,
1669
1671
& including_downcast,
@@ -1672,8 +1674,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1672
1674
}
1673
1675
}
1674
1676
ProjectionElem :: Downcast ( ..) => {
1677
+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1675
1678
self . append_place_to_string (
1676
- & proj . base ,
1679
+ & neo_place ,
1677
1680
buf,
1678
1681
autoderef,
1679
1682
& including_downcast,
@@ -1691,9 +1694,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1691
1694
let name = self . mir . upvar_decls [ var_index] . debug_name . to_string ( ) ;
1692
1695
buf. push_str ( & name) ;
1693
1696
} 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) ;
1695
1699
self . append_place_to_string (
1696
- & proj . base ,
1700
+ & neo_place ,
1697
1701
buf,
1698
1702
autoderef,
1699
1703
& including_downcast,
@@ -1704,8 +1708,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1704
1708
ProjectionElem :: Index ( index) => {
1705
1709
autoderef = true ;
1706
1710
1711
+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1707
1712
self . append_place_to_string (
1708
- & proj . base ,
1713
+ & neo_place ,
1709
1714
buf,
1710
1715
autoderef,
1711
1716
& including_downcast,
@@ -1718,11 +1723,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1718
1723
}
1719
1724
ProjectionElem :: ConstantIndex { .. } | ProjectionElem :: Subslice { .. } => {
1720
1725
autoderef = true ;
1726
+ let neo_place = self . infcx . tcx . as_new_place ( & proj. base ) ;
1721
1727
// Since it isn't possible to borrow an element on a particular index and
1722
1728
// then use another while the borrow is held, don't output indices details
1723
1729
// to avoid confusing the end-user
1724
1730
self . append_place_to_string (
1725
- & proj . base ,
1731
+ & neo_place ,
1726
1732
buf,
1727
1733
autoderef,
1728
1734
& including_downcast,
@@ -1752,16 +1758,19 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1752
1758
/// End-user visible description of the `field`nth field of `base`
1753
1759
fn describe_field ( & self , base : & NeoPlace < ' tcx > , field : Field ) -> String {
1754
1760
match base. clone ( ) . into_tree ( ) {
1755
- NeoPlaceTree :: Base ( PlaceBase :: Local ( local) ) => {
1761
+ Place :: Local ( local) => {
1756
1762
let local = & self . mir . local_decls [ local] ;
1757
1763
self . describe_field_from_ty ( & local. ty , field)
1758
1764
}
1759
- NeoPlaceTree :: Base ( PlaceBase :: Promoted ( ref prom) ) =>
1765
+ Place :: Promoted ( ref prom) =>
1760
1766
self . describe_field_from_ty ( & prom. 1 , field) ,
1761
- NeoPlaceTree :: Base ( PlaceBase :: Static ( ref static_) ) =>
1767
+ Place :: Static ( ref static_) =>
1762
1768
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
+ }
1765
1774
ProjectionElem :: Downcast ( def, variant_index) =>
1766
1775
def. variants [ variant_index] . fields [ field. index ( ) ] . ident . to_string ( ) ,
1767
1776
ProjectionElem :: Field ( _, field_type) => {
@@ -1770,7 +1779,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1770
1779
ProjectionElem :: Index ( ..)
1771
1780
| ProjectionElem :: ConstantIndex { .. }
1772
1781
| 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)
1774
1784
}
1775
1785
} ,
1776
1786
}
0 commit comments