@@ -1663,22 +1663,14 @@ impl Debug for Statement<'_> {
16631663 Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , HashStable ,
16641664) ]
16651665pub struct Place < ' tcx > {
1666- pub base : PlaceBase ,
1666+ pub local : Local ,
16671667
16681668 /// projection out of a place (access a field, deref a pointer, etc)
16691669 pub projection : & ' tcx List < PlaceElem < ' tcx > > ,
16701670}
16711671
16721672impl < ' tcx > rustc_serialize:: UseSpecializedDecodable for Place < ' tcx > { }
16731673
1674- #[ derive(
1675- Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable , HashStable ,
1676- ) ]
1677- pub enum PlaceBase {
1678- /// local variable
1679- Local ( Local ) ,
1680- }
1681-
16821674#[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
16831675#[ derive( RustcEncodable , RustcDecodable , HashStable ) ]
16841676pub enum ProjectionElem < V , T > {
@@ -1767,15 +1759,15 @@ rustc_index::newtype_index! {
17671759
17681760#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
17691761pub struct PlaceRef < ' a , ' tcx > {
1770- pub base : & ' a PlaceBase ,
1762+ pub local : & ' a Local ,
17711763 pub projection : & ' a [ PlaceElem < ' tcx > ] ,
17721764}
17731765
17741766impl < ' tcx > Place < ' tcx > {
17751767 // FIXME change this to a const fn by also making List::empty a const fn.
17761768 pub fn return_place ( ) -> Place < ' tcx > {
17771769 Place {
1778- base : PlaceBase :: Local ( RETURN_PLACE ) ,
1770+ local : RETURN_PLACE ,
17791771 projection : List :: empty ( ) ,
17801772 }
17811773 }
@@ -1795,13 +1787,13 @@ impl<'tcx> Place<'tcx> {
17951787 pub fn local_or_deref_local ( & self ) -> Option < Local > {
17961788 match self . as_ref ( ) {
17971789 PlaceRef {
1798- base : & PlaceBase :: Local ( local) ,
1790+ local,
17991791 projection : & [ ] ,
18001792 } |
18011793 PlaceRef {
1802- base : & PlaceBase :: Local ( local) ,
1794+ local,
18031795 projection : & [ ProjectionElem :: Deref ] ,
1804- } => Some ( local) ,
1796+ } => Some ( * local) ,
18051797 _ => None ,
18061798 }
18071799 }
@@ -1814,7 +1806,7 @@ impl<'tcx> Place<'tcx> {
18141806
18151807 pub fn as_ref ( & self ) -> PlaceRef < ' _ , ' tcx > {
18161808 PlaceRef {
1817- base : & self . base ,
1809+ local : & self . local ,
18181810 projection : & self . projection ,
18191811 }
18201812 }
@@ -1823,18 +1815,12 @@ impl<'tcx> Place<'tcx> {
18231815impl From < Local > for Place < ' _ > {
18241816 fn from ( local : Local ) -> Self {
18251817 Place {
1826- base : local. into ( ) ,
1818+ local : local. into ( ) ,
18271819 projection : List :: empty ( ) ,
18281820 }
18291821 }
18301822}
18311823
1832- impl From < Local > for PlaceBase {
1833- fn from ( local : Local ) -> Self {
1834- PlaceBase :: Local ( local)
1835- }
1836- }
1837-
18381824impl < ' a , ' tcx > PlaceRef < ' a , ' tcx > {
18391825 /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
18401826 /// a single deref of a local.
@@ -1843,13 +1829,13 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
18431829 pub fn local_or_deref_local ( & self ) -> Option < Local > {
18441830 match self {
18451831 PlaceRef {
1846- base : PlaceBase :: Local ( local) ,
1832+ local,
18471833 projection : [ ] ,
18481834 } |
18491835 PlaceRef {
1850- base : PlaceBase :: Local ( local) ,
1836+ local,
18511837 projection : [ ProjectionElem :: Deref ] ,
1852- } => Some ( * local) ,
1838+ } => Some ( * * local) ,
18531839 _ => None ,
18541840 }
18551841 }
@@ -1858,7 +1844,7 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
18581844 /// projections, return `Some(_X)`.
18591845 pub fn as_local ( & self ) -> Option < Local > {
18601846 match self {
1861- PlaceRef { base : PlaceBase :: Local ( l ) , projection : [ ] } => Some ( * l ) ,
1847+ PlaceRef { local , projection : [ ] } => Some ( * * local ) ,
18621848 _ => None ,
18631849 }
18641850 }
@@ -1880,7 +1866,7 @@ impl Debug for Place<'_> {
18801866 }
18811867 }
18821868
1883- write ! ( fmt, "{:?}" , self . base ) ?;
1869+ write ! ( fmt, "{:?}" , self . local ) ?;
18841870
18851871 for elem in self . projection . iter ( ) {
18861872 match elem {
@@ -1924,14 +1910,6 @@ impl Debug for Place<'_> {
19241910 }
19251911}
19261912
1927- impl Debug for PlaceBase {
1928- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1929- match * self {
1930- PlaceBase :: Local ( id) => write ! ( fmt, "{:?}" , id) ,
1931- }
1932- }
1933- }
1934-
19351913///////////////////////////////////////////////////////////////////////////
19361914// Scopes
19371915
@@ -2995,27 +2973,13 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
29952973impl < ' tcx > TypeFoldable < ' tcx > for Place < ' tcx > {
29962974 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
29972975 Place {
2998- base : self . base . fold_with ( folder) ,
2976+ local : self . local . fold_with ( folder) ,
29992977 projection : self . projection . fold_with ( folder) ,
30002978 }
30012979 }
30022980
30032981 fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
3004- self . base . visit_with ( visitor) || self . projection . visit_with ( visitor)
3005- }
3006- }
3007-
3008- impl < ' tcx > TypeFoldable < ' tcx > for PlaceBase {
3009- fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
3010- match self {
3011- PlaceBase :: Local ( local) => PlaceBase :: Local ( local. fold_with ( folder) ) ,
3012- }
3013- }
3014-
3015- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
3016- match self {
3017- PlaceBase :: Local ( local) => local. visit_with ( visitor) ,
3018- }
2982+ self . local . visit_with ( visitor) || self . projection . visit_with ( visitor)
30192983 }
30202984}
30212985
0 commit comments