@@ -1655,20 +1655,14 @@ impl Debug for Statement<'_> {
16551655/// changing or disturbing program state.
16561656#[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , HashStable ) ]
16571657pub struct Place < ' tcx > {
1658- pub base : PlaceBase ,
1658+ pub local : Local ,
16591659
16601660 /// projection out of a place (access a field, deref a pointer, etc)
16611661 pub projection : & ' tcx List < PlaceElem < ' tcx > > ,
16621662}
16631663
16641664impl < ' tcx > rustc_serialize:: UseSpecializedDecodable for Place < ' tcx > { }
16651665
1666- #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable , HashStable ) ]
1667- pub enum PlaceBase {
1668- /// local variable
1669- Local ( Local ) ,
1670- }
1671-
16721666#[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
16731667#[ derive( RustcEncodable , RustcDecodable , HashStable ) ]
16741668pub enum ProjectionElem < V , T > {
@@ -1756,14 +1750,14 @@ rustc_index::newtype_index! {
17561750
17571751#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
17581752pub struct PlaceRef < ' a , ' tcx > {
1759- pub base : & ' a PlaceBase ,
1753+ pub local : & ' a Local ,
17601754 pub projection : & ' a [ PlaceElem < ' tcx > ] ,
17611755}
17621756
17631757impl < ' tcx > Place < ' tcx > {
17641758 // FIXME change this to a const fn by also making List::empty a const fn.
17651759 pub fn return_place ( ) -> Place < ' tcx > {
1766- Place { base : PlaceBase :: Local ( RETURN_PLACE ) , projection : List :: empty ( ) }
1760+ Place { local : RETURN_PLACE , projection : List :: empty ( ) }
17671761 }
17681762
17691763 /// Returns `true` if this `Place` contains a `Deref` projection.
@@ -1780,10 +1774,8 @@ impl<'tcx> Place<'tcx> {
17801774 // FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
17811775 pub fn local_or_deref_local ( & self ) -> Option < Local > {
17821776 match self . as_ref ( ) {
1783- PlaceRef { base : & PlaceBase :: Local ( local) , projection : & [ ] }
1784- | PlaceRef { base : & PlaceBase :: Local ( local) , projection : & [ ProjectionElem :: Deref ] } => {
1785- Some ( local)
1786- }
1777+ PlaceRef { local, projection : & [ ] }
1778+ | PlaceRef { local, projection : & [ ProjectionElem :: Deref ] } => Some ( * local) ,
17871779 _ => None ,
17881780 }
17891781 }
@@ -1795,19 +1787,13 @@ impl<'tcx> Place<'tcx> {
17951787 }
17961788
17971789 pub fn as_ref ( & self ) -> PlaceRef < ' _ , ' tcx > {
1798- PlaceRef { base : & self . base , projection : & self . projection }
1790+ PlaceRef { local : & self . local , projection : & self . projection }
17991791 }
18001792}
18011793
18021794impl From < Local > for Place < ' _ > {
18031795 fn from ( local : Local ) -> Self {
1804- Place { base : local. into ( ) , projection : List :: empty ( ) }
1805- }
1806- }
1807-
1808- impl From < Local > for PlaceBase {
1809- fn from ( local : Local ) -> Self {
1810- PlaceBase :: Local ( local)
1796+ Place { local : local. into ( ) , projection : List :: empty ( ) }
18111797 }
18121798}
18131799
@@ -1818,10 +1804,8 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
18181804 // FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
18191805 pub fn local_or_deref_local ( & self ) -> Option < Local > {
18201806 match self {
1821- PlaceRef { base : PlaceBase :: Local ( local) , projection : [ ] }
1822- | PlaceRef { base : PlaceBase :: Local ( local) , projection : [ ProjectionElem :: Deref ] } => {
1823- Some ( * local)
1824- }
1807+ PlaceRef { local, projection : [ ] }
1808+ | PlaceRef { local, projection : [ ProjectionElem :: Deref ] } => Some ( * * local) ,
18251809 _ => None ,
18261810 }
18271811 }
@@ -1830,7 +1814,7 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
18301814 /// projections, return `Some(_X)`.
18311815 pub fn as_local ( & self ) -> Option < Local > {
18321816 match self {
1833- PlaceRef { base : PlaceBase :: Local ( l ) , projection : [ ] } => Some ( * l ) ,
1817+ PlaceRef { local , projection : [ ] } => Some ( * * local ) ,
18341818 _ => None ,
18351819 }
18361820 }
@@ -1852,7 +1836,7 @@ impl Debug for Place<'_> {
18521836 }
18531837 }
18541838
1855- write ! ( fmt, "{:?}" , self . base ) ?;
1839+ write ! ( fmt, "{:?}" , self . local ) ?;
18561840
18571841 for elem in self . projection . iter ( ) {
18581842 match elem {
@@ -1896,14 +1880,6 @@ impl Debug for Place<'_> {
18961880 }
18971881}
18981882
1899- impl Debug for PlaceBase {
1900- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1901- match * self {
1902- PlaceBase :: Local ( id) => write ! ( fmt, "{:?}" , id) ,
1903- }
1904- }
1905- }
1906-
19071883///////////////////////////////////////////////////////////////////////////
19081884// Scopes
19091885
@@ -2964,25 +2940,11 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
29642940
29652941impl < ' tcx > TypeFoldable < ' tcx > for Place < ' tcx > {
29662942 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
2967- Place { base : self . base . fold_with ( folder) , projection : self . projection . fold_with ( folder) }
2943+ Place { local : self . local . fold_with ( folder) , projection : self . projection . fold_with ( folder) }
29682944 }
29692945
29702946 fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
2971- self . base . visit_with ( visitor) || self . projection . visit_with ( visitor)
2972- }
2973- }
2974-
2975- impl < ' tcx > TypeFoldable < ' tcx > for PlaceBase {
2976- fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
2977- match self {
2978- PlaceBase :: Local ( local) => PlaceBase :: Local ( local. fold_with ( folder) ) ,
2979- }
2980- }
2981-
2982- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
2983- match self {
2984- PlaceBase :: Local ( local) => local. visit_with ( visitor) ,
2985- }
2947+ self . local . visit_with ( visitor) || self . projection . visit_with ( visitor)
29862948 }
29872949}
29882950
0 commit comments