@@ -1663,22 +1663,14 @@ impl Debug for Statement<'_> {
1663
1663
Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , HashStable ,
1664
1664
) ]
1665
1665
pub struct Place < ' tcx > {
1666
- pub base : PlaceBase ,
1666
+ pub local : Local ,
1667
1667
1668
1668
/// projection out of a place (access a field, deref a pointer, etc)
1669
1669
pub projection : & ' tcx List < PlaceElem < ' tcx > > ,
1670
1670
}
1671
1671
1672
1672
impl < ' tcx > rustc_serialize:: UseSpecializedDecodable for Place < ' tcx > { }
1673
1673
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
-
1682
1674
#[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
1683
1675
#[ derive( RustcEncodable , RustcDecodable , HashStable ) ]
1684
1676
pub enum ProjectionElem < V , T > {
@@ -1767,15 +1759,15 @@ rustc_index::newtype_index! {
1767
1759
1768
1760
#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
1769
1761
pub struct PlaceRef < ' a , ' tcx > {
1770
- pub base : & ' a PlaceBase ,
1762
+ pub local : & ' a Local ,
1771
1763
pub projection : & ' a [ PlaceElem < ' tcx > ] ,
1772
1764
}
1773
1765
1774
1766
impl < ' tcx > Place < ' tcx > {
1775
1767
// FIXME change this to a const fn by also making List::empty a const fn.
1776
1768
pub fn return_place ( ) -> Place < ' tcx > {
1777
1769
Place {
1778
- base : PlaceBase :: Local ( RETURN_PLACE ) ,
1770
+ local : RETURN_PLACE ,
1779
1771
projection : List :: empty ( ) ,
1780
1772
}
1781
1773
}
@@ -1795,13 +1787,13 @@ impl<'tcx> Place<'tcx> {
1795
1787
pub fn local_or_deref_local ( & self ) -> Option < Local > {
1796
1788
match self . as_ref ( ) {
1797
1789
PlaceRef {
1798
- base : & PlaceBase :: Local ( local) ,
1790
+ local,
1799
1791
projection : & [ ] ,
1800
1792
} |
1801
1793
PlaceRef {
1802
- base : & PlaceBase :: Local ( local) ,
1794
+ local,
1803
1795
projection : & [ ProjectionElem :: Deref ] ,
1804
- } => Some ( local) ,
1796
+ } => Some ( * local) ,
1805
1797
_ => None ,
1806
1798
}
1807
1799
}
@@ -1814,7 +1806,7 @@ impl<'tcx> Place<'tcx> {
1814
1806
1815
1807
pub fn as_ref ( & self ) -> PlaceRef < ' _ , ' tcx > {
1816
1808
PlaceRef {
1817
- base : & self . base ,
1809
+ local : & self . local ,
1818
1810
projection : & self . projection ,
1819
1811
}
1820
1812
}
@@ -1823,18 +1815,12 @@ impl<'tcx> Place<'tcx> {
1823
1815
impl From < Local > for Place < ' _ > {
1824
1816
fn from ( local : Local ) -> Self {
1825
1817
Place {
1826
- base : local. into ( ) ,
1818
+ local : local. into ( ) ,
1827
1819
projection : List :: empty ( ) ,
1828
1820
}
1829
1821
}
1830
1822
}
1831
1823
1832
- impl From < Local > for PlaceBase {
1833
- fn from ( local : Local ) -> Self {
1834
- PlaceBase :: Local ( local)
1835
- }
1836
- }
1837
-
1838
1824
impl < ' a , ' tcx > PlaceRef < ' a , ' tcx > {
1839
1825
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
1840
1826
/// a single deref of a local.
@@ -1843,13 +1829,13 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
1843
1829
pub fn local_or_deref_local ( & self ) -> Option < Local > {
1844
1830
match self {
1845
1831
PlaceRef {
1846
- base : PlaceBase :: Local ( local) ,
1832
+ local,
1847
1833
projection : [ ] ,
1848
1834
} |
1849
1835
PlaceRef {
1850
- base : PlaceBase :: Local ( local) ,
1836
+ local,
1851
1837
projection : [ ProjectionElem :: Deref ] ,
1852
- } => Some ( * local) ,
1838
+ } => Some ( * * local) ,
1853
1839
_ => None ,
1854
1840
}
1855
1841
}
@@ -1858,7 +1844,7 @@ impl<'a, 'tcx> PlaceRef<'a, 'tcx> {
1858
1844
/// projections, return `Some(_X)`.
1859
1845
pub fn as_local ( & self ) -> Option < Local > {
1860
1846
match self {
1861
- PlaceRef { base : PlaceBase :: Local ( l ) , projection : [ ] } => Some ( * l ) ,
1847
+ PlaceRef { local , projection : [ ] } => Some ( * * local ) ,
1862
1848
_ => None ,
1863
1849
}
1864
1850
}
@@ -1880,7 +1866,7 @@ impl Debug for Place<'_> {
1880
1866
}
1881
1867
}
1882
1868
1883
- write ! ( fmt, "{:?}" , self . base ) ?;
1869
+ write ! ( fmt, "{:?}" , self . local ) ?;
1884
1870
1885
1871
for elem in self . projection . iter ( ) {
1886
1872
match elem {
@@ -1924,14 +1910,6 @@ impl Debug for Place<'_> {
1924
1910
}
1925
1911
}
1926
1912
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
-
1935
1913
///////////////////////////////////////////////////////////////////////////
1936
1914
// Scopes
1937
1915
@@ -2995,27 +2973,13 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
2995
2973
impl < ' tcx > TypeFoldable < ' tcx > for Place < ' tcx > {
2996
2974
fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
2997
2975
Place {
2998
- base : self . base . fold_with ( folder) ,
2976
+ local : self . local . fold_with ( folder) ,
2999
2977
projection : self . projection . fold_with ( folder) ,
3000
2978
}
3001
2979
}
3002
2980
3003
2981
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)
3019
2983
}
3020
2984
}
3021
2985
0 commit comments