@@ -1914,7 +1914,7 @@ pub enum Place<'tcx> {
1914
1914
Base ( PlaceBase < ' tcx > ) ,
1915
1915
1916
1916
/// projection out of a place (access a field, deref a pointer, etc)
1917
- Projection ( Box < PlaceProjection < ' tcx > > ) ,
1917
+ Projection ( Box < Projection < ' tcx > > ) ,
1918
1918
}
1919
1919
1920
1920
#[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable , HashStable ) ]
@@ -1944,16 +1944,13 @@ impl_stable_hash_for!(struct Static<'tcx> {
1944
1944
kind
1945
1945
} ) ;
1946
1946
1947
- /// The `Projection` data structure defines things of the form `B.x`
1948
- /// or `*B` or `B[index]`. Note that it is parameterized because it is
1949
- /// shared between `Constant` and `Place`. See the aliases
1950
- /// `PlaceProjection` etc below.
1947
+ /// The `Projection` data structure defines things of the form `base.x`, `*b` or `b[index]`.
1951
1948
#[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord ,
1952
1949
Hash , RustcEncodable , RustcDecodable , HashStable ) ]
1953
- pub struct Projection < B , V , T > {
1954
- pub base : B ,
1955
- pub elem : ProjectionElem < V , T > ,
1956
- }
1950
+ pub struct Projection < ' tcx > {
1951
+ pub base : Place < ' tcx > ,
1952
+ pub elem : PlaceElem < ' tcx > ,
1953
+ }
1957
1954
1958
1955
#[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord ,
1959
1956
Hash , RustcEncodable , RustcDecodable , HashStable ) ]
@@ -1996,10 +1993,6 @@ pub enum ProjectionElem<V, T> {
1996
1993
Downcast ( Option < Symbol > , VariantIdx ) ,
1997
1994
}
1998
1995
1999
- /// Alias for projections as they appear in places, where the base is a place
2000
- /// and the index is a local.
2001
- pub type PlaceProjection < ' tcx > = Projection < Place < ' tcx > , Local , Ty < ' tcx > > ;
2002
-
2003
1996
/// Alias for projections as they appear in places, where the base is a place
2004
1997
/// and the index is a local.
2005
1998
pub type PlaceElem < ' tcx > = ProjectionElem < Local , Ty < ' tcx > > ;
@@ -2045,7 +2038,7 @@ impl<'tcx> Place<'tcx> {
2045
2038
}
2046
2039
2047
2040
pub fn elem ( self , elem : PlaceElem < ' tcx > ) -> Place < ' tcx > {
2048
- Place :: Projection ( Box :: new ( PlaceProjection { base : self , elem } ) )
2041
+ Place :: Projection ( Box :: new ( Projection { base : self , elem } ) )
2049
2042
}
2050
2043
2051
2044
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
@@ -2076,22 +2069,22 @@ impl<'tcx> Place<'tcx> {
2076
2069
}
2077
2070
2078
2071
/// Recursively "iterates" over place components, generating a `PlaceBase` and
2079
- /// `PlaceProjections ` list and invoking `op` with a `PlaceProjectionsIter `.
2072
+ /// `Projections ` list and invoking `op` with a `ProjectionsIter `.
2080
2073
pub fn iterate < R > (
2081
2074
& self ,
2082
- op : impl FnOnce ( & PlaceBase < ' tcx > , PlaceProjectionsIter < ' _ , ' tcx > ) -> R ,
2075
+ op : impl FnOnce ( & PlaceBase < ' tcx > , ProjectionsIter < ' _ , ' tcx > ) -> R ,
2083
2076
) -> R {
2084
- self . iterate2 ( & PlaceProjections :: Empty , op)
2077
+ self . iterate2 ( & Projections :: Empty , op)
2085
2078
}
2086
2079
2087
2080
fn iterate2 < R > (
2088
2081
& self ,
2089
- next : & PlaceProjections < ' _ , ' tcx > ,
2090
- op : impl FnOnce ( & PlaceBase < ' tcx > , PlaceProjectionsIter < ' _ , ' tcx > ) -> R ,
2082
+ next : & Projections < ' _ , ' tcx > ,
2083
+ op : impl FnOnce ( & PlaceBase < ' tcx > , ProjectionsIter < ' _ , ' tcx > ) -> R ,
2091
2084
) -> R {
2092
2085
match self {
2093
2086
Place :: Projection ( interior) => interior. base . iterate2 (
2094
- & PlaceProjections :: List {
2087
+ & Projections :: List {
2095
2088
projection : interior,
2096
2089
next,
2097
2090
} ,
@@ -2111,26 +2104,26 @@ impl<'tcx> Place<'tcx> {
2111
2104
/// N.B., this particular impl strategy is not the most obvious. It was
2112
2105
/// chosen because it makes a measurable difference to NLL
2113
2106
/// performance, as this code (`borrow_conflicts_with_place`) is somewhat hot.
2114
- pub enum PlaceProjections < ' p , ' tcx : ' p > {
2107
+ pub enum Projections < ' p , ' tcx : ' p > {
2115
2108
Empty ,
2116
2109
2117
2110
List {
2118
- projection : & ' p PlaceProjection < ' tcx > ,
2119
- next : & ' p PlaceProjections < ' p , ' tcx > ,
2111
+ projection : & ' p Projection < ' tcx > ,
2112
+ next : & ' p Projections < ' p , ' tcx > ,
2120
2113
}
2121
2114
}
2122
2115
2123
- impl < ' p , ' tcx > PlaceProjections < ' p , ' tcx > {
2124
- fn iter ( & self ) -> PlaceProjectionsIter < ' _ , ' tcx > {
2125
- PlaceProjectionsIter { value : self }
2116
+ impl < ' p , ' tcx > Projections < ' p , ' tcx > {
2117
+ fn iter ( & self ) -> ProjectionsIter < ' _ , ' tcx > {
2118
+ ProjectionsIter { value : self }
2126
2119
}
2127
2120
}
2128
2121
2129
- impl < ' p , ' tcx > IntoIterator for & ' p PlaceProjections < ' p , ' tcx > {
2130
- type Item = & ' p PlaceProjection < ' tcx > ;
2131
- type IntoIter = PlaceProjectionsIter < ' p , ' tcx > ;
2122
+ impl < ' p , ' tcx > IntoIterator for & ' p Projections < ' p , ' tcx > {
2123
+ type Item = & ' p Projection < ' tcx > ;
2124
+ type IntoIter = ProjectionsIter < ' p , ' tcx > ;
2132
2125
2133
- /// Converts a list of `PlaceProjection ` components into an iterator;
2126
+ /// Converts a list of `Projection ` components into an iterator;
2134
2127
/// this iterator yields up a never-ending stream of `Option<&Place>`.
2135
2128
/// These begin with the "innermost" projection and then with each
2136
2129
/// projection therefrom. So given a place like `a.b.c` it would
@@ -2144,21 +2137,21 @@ impl<'p, 'tcx> IntoIterator for &'p PlaceProjections<'p, 'tcx> {
2144
2137
}
2145
2138
}
2146
2139
2147
- /// Iterator over components; see `PlaceProjections ::iter` for more
2140
+ /// Iterator over components; see `Projections ::iter` for more
2148
2141
/// information.
2149
2142
///
2150
2143
/// N.B., this is not a *true* Rust iterator -- the code above just
2151
2144
/// manually invokes `next`. This is because we (sometimes) want to
2152
2145
/// keep executing even after `None` has been returned.
2153
- pub struct PlaceProjectionsIter < ' p , ' tcx : ' p > {
2154
- pub value : & ' p PlaceProjections < ' p , ' tcx > ,
2146
+ pub struct ProjectionsIter < ' p , ' tcx : ' p > {
2147
+ pub value : & ' p Projections < ' p , ' tcx > ,
2155
2148
}
2156
2149
2157
- impl < ' p , ' tcx > Iterator for PlaceProjectionsIter < ' p , ' tcx > {
2158
- type Item = & ' p PlaceProjection < ' tcx > ;
2150
+ impl < ' p , ' tcx > Iterator for ProjectionsIter < ' p , ' tcx > {
2151
+ type Item = & ' p Projection < ' tcx > ;
2159
2152
2160
2153
fn next ( & mut self ) -> Option < Self :: Item > {
2161
- if let & PlaceProjections :: List { projection, next } = self . value {
2154
+ if let & Projections :: List { projection, next } = self . value {
2162
2155
self . value = next;
2163
2156
Some ( projection)
2164
2157
} else {
@@ -2167,7 +2160,7 @@ impl<'p, 'tcx> Iterator for PlaceProjectionsIter<'p, 'tcx> {
2167
2160
}
2168
2161
}
2169
2162
2170
- impl < ' p , ' tcx > FusedIterator for PlaceProjectionsIter < ' p , ' tcx > { }
2163
+ impl < ' p , ' tcx > FusedIterator for ProjectionsIter < ' p , ' tcx > { }
2171
2164
2172
2165
impl < ' tcx > Debug for Place < ' tcx > {
2173
2166
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
@@ -2758,7 +2751,7 @@ impl<'tcx> UserTypeProjections {
2758
2751
#[ derive( Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable , HashStable ) ]
2759
2752
pub struct UserTypeProjection {
2760
2753
pub base : UserTypeAnnotationIndex ,
2761
- pub projs : Vec < ProjectionElem < ( ) , ( ) > > ,
2754
+ pub projs : Vec < ProjectionKind > ,
2762
2755
}
2763
2756
2764
2757
impl Copy for ProjectionKind { }
@@ -3587,12 +3580,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
3587
3580
}
3588
3581
}
3589
3582
3590
- impl < ' tcx , B , V , T > TypeFoldable < ' tcx > for Projection < B , V , T >
3591
- where
3592
- B : TypeFoldable < ' tcx > ,
3593
- V : TypeFoldable < ' tcx > ,
3594
- T : TypeFoldable < ' tcx > ,
3595
- {
3583
+ impl < ' tcx > TypeFoldable < ' tcx > for Projection < ' tcx > {
3596
3584
fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
3597
3585
use crate :: mir:: ProjectionElem :: * ;
3598
3586
0 commit comments