@@ -108,11 +108,6 @@ pub struct Body<'tcx> {
108
108
/// needn't) be tracked across crates.
109
109
pub source_scope_local_data : ClearCrossCrate < IndexVec < SourceScope , SourceScopeLocalData > > ,
110
110
111
- /// Rvalues promoted from this function, such as borrows of constants.
112
- /// Each of them is the Body of a constant with the fn's type parameters
113
- /// in scope, but a separate set of locals.
114
- pub promoted : IndexVec < Promoted , Body < ' tcx > > ,
115
-
116
111
/// Yields type of the function, if it is a generator.
117
112
pub yield_ty : Option < Ty < ' tcx > > ,
118
113
@@ -174,7 +169,6 @@ impl<'tcx> Body<'tcx> {
174
169
basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
175
170
source_scopes : IndexVec < SourceScope , SourceScopeData > ,
176
171
source_scope_local_data : ClearCrossCrate < IndexVec < SourceScope , SourceScopeLocalData > > ,
177
- promoted : IndexVec < Promoted , Body < ' tcx > > ,
178
172
yield_ty : Option < Ty < ' tcx > > ,
179
173
local_decls : LocalDecls < ' tcx > ,
180
174
user_type_annotations : CanonicalUserTypeAnnotations < ' tcx > ,
@@ -196,7 +190,6 @@ impl<'tcx> Body<'tcx> {
196
190
basic_blocks,
197
191
source_scopes,
198
192
source_scope_local_data,
199
- promoted,
200
193
yield_ty,
201
194
generator_drop : None ,
202
195
generator_layout : None ,
@@ -418,7 +411,6 @@ impl_stable_hash_for!(struct Body<'tcx> {
418
411
basic_blocks,
419
412
source_scopes,
420
413
source_scope_local_data,
421
- promoted,
422
414
yield_ty,
423
415
generator_drop,
424
416
generator_layout,
@@ -1737,23 +1729,25 @@ pub enum PlaceBase<'tcx> {
1737
1729
}
1738
1730
1739
1731
/// We store the normalized type to avoid requiring normalization when reading MIR
1740
- #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
1732
+ #[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
1741
1733
pub struct Static < ' tcx > {
1742
1734
pub ty : Ty < ' tcx > ,
1743
- pub kind : StaticKind ,
1735
+ pub kind : StaticKind < ' tcx > ,
1736
+ pub def_id : DefId ,
1744
1737
}
1745
1738
1746
1739
#[ derive(
1747
- Clone , PartialEq , Eq , PartialOrd , Ord , Hash , HashStable , RustcEncodable , RustcDecodable ,
1740
+ Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , HashStable , RustcEncodable , RustcDecodable ,
1748
1741
) ]
1749
- pub enum StaticKind {
1750
- Promoted ( Promoted ) ,
1751
- Static ( DefId ) ,
1742
+ pub enum StaticKind < ' tcx > {
1743
+ Promoted ( Promoted , SubstsRef < ' tcx > ) ,
1744
+ Static ,
1752
1745
}
1753
1746
1754
1747
impl_stable_hash_for ! ( struct Static <' tcx> {
1755
1748
ty,
1756
- kind
1749
+ kind,
1750
+ def_id
1757
1751
} ) ;
1758
1752
1759
1753
/// The `Projection` data structure defines things of the form `base.x`, `*b` or `b[index]`.
@@ -2114,10 +2108,12 @@ impl Debug for PlaceBase<'_> {
2114
2108
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
2115
2109
match * self {
2116
2110
PlaceBase :: Local ( id) => write ! ( fmt, "{:?}" , id) ,
2117
- PlaceBase :: Static ( box self :: Static { ty, kind : StaticKind :: Static ( def_id) } ) => {
2111
+ PlaceBase :: Static ( box self :: Static { ty, kind : StaticKind :: Static , def_id } ) => {
2118
2112
write ! ( fmt, "({}: {:?})" , ty:: tls:: with( |tcx| tcx. def_path_str( def_id) ) , ty)
2119
2113
}
2120
- PlaceBase :: Static ( box self :: Static { ty, kind : StaticKind :: Promoted ( promoted) } ) => {
2114
+ PlaceBase :: Static ( box self :: Static {
2115
+ ty, kind : StaticKind :: Promoted ( promoted, _) , def_id : _
2116
+ } ) => {
2121
2117
write ! ( fmt, "({:?}: {:?})" , promoted, ty)
2122
2118
}
2123
2119
}
@@ -3032,7 +3028,6 @@ BraceStructTypeFoldableImpl! {
3032
3028
basic_blocks,
3033
3029
source_scopes,
3034
3030
source_scope_local_data,
3035
- promoted,
3036
3031
yield_ty,
3037
3032
generator_drop,
3038
3033
generator_layout,
@@ -3226,13 +3221,63 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
3226
3221
impl < ' tcx > TypeFoldable < ' tcx > for Place < ' tcx > {
3227
3222
fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
3228
3223
Place {
3229
- base : self . base . clone ( ) ,
3224
+ base : self . base . fold_with ( folder ) ,
3230
3225
projection : self . projection . fold_with ( folder) ,
3231
3226
}
3232
3227
}
3233
3228
3234
3229
fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
3235
- self . projection . visit_with ( visitor)
3230
+ self . base . visit_with ( visitor) || self . projection . visit_with ( visitor)
3231
+ }
3232
+ }
3233
+
3234
+ impl < ' tcx > TypeFoldable < ' tcx > for PlaceBase < ' tcx > {
3235
+ fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
3236
+ match self {
3237
+ PlaceBase :: Local ( local) => PlaceBase :: Local ( local. fold_with ( folder) ) ,
3238
+ PlaceBase :: Static ( static_) => PlaceBase :: Static ( static_. fold_with ( folder) ) ,
3239
+ }
3240
+ }
3241
+
3242
+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
3243
+ match self {
3244
+ PlaceBase :: Local ( local) => local. visit_with ( visitor) ,
3245
+ PlaceBase :: Static ( static_) => ( * * static_) . visit_with ( visitor) ,
3246
+ }
3247
+ }
3248
+ }
3249
+
3250
+ impl < ' tcx > TypeFoldable < ' tcx > for Static < ' tcx > {
3251
+ fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
3252
+ Static {
3253
+ ty : self . ty . fold_with ( folder) ,
3254
+ kind : self . kind . fold_with ( folder) ,
3255
+ def_id : self . def_id ,
3256
+ }
3257
+ }
3258
+
3259
+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
3260
+ let Static { ty, kind, def_id : _ } = self ;
3261
+
3262
+ ty. visit_with ( visitor) || kind. visit_with ( visitor)
3263
+ }
3264
+ }
3265
+
3266
+ impl < ' tcx > TypeFoldable < ' tcx > for StaticKind < ' tcx > {
3267
+ fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
3268
+ match self {
3269
+ StaticKind :: Promoted ( promoted, substs) =>
3270
+ StaticKind :: Promoted ( promoted. fold_with ( folder) , substs. fold_with ( folder) ) ,
3271
+ StaticKind :: Static => StaticKind :: Static
3272
+ }
3273
+ }
3274
+
3275
+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
3276
+ match self {
3277
+ StaticKind :: Promoted ( promoted, substs) =>
3278
+ promoted. visit_with ( visitor) || substs. visit_with ( visitor) ,
3279
+ StaticKind :: Static => { false }
3280
+ }
3236
3281
}
3237
3282
}
3238
3283
0 commit comments