@@ -108,11 +108,6 @@ pub struct Body<'tcx> {
108108 /// needn't) be tracked across crates.
109109 pub source_scope_local_data : ClearCrossCrate < IndexVec < SourceScope , SourceScopeLocalData > > ,
110110
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-
116111 /// Yields type of the function, if it is a generator.
117112 pub yield_ty : Option < Ty < ' tcx > > ,
118113
@@ -174,7 +169,6 @@ impl<'tcx> Body<'tcx> {
174169 basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
175170 source_scopes : IndexVec < SourceScope , SourceScopeData > ,
176171 source_scope_local_data : ClearCrossCrate < IndexVec < SourceScope , SourceScopeLocalData > > ,
177- promoted : IndexVec < Promoted , Body < ' tcx > > ,
178172 yield_ty : Option < Ty < ' tcx > > ,
179173 local_decls : LocalDecls < ' tcx > ,
180174 user_type_annotations : CanonicalUserTypeAnnotations < ' tcx > ,
@@ -196,7 +190,6 @@ impl<'tcx> Body<'tcx> {
196190 basic_blocks,
197191 source_scopes,
198192 source_scope_local_data,
199- promoted,
200193 yield_ty,
201194 generator_drop : None ,
202195 generator_layout : None ,
@@ -418,7 +411,6 @@ impl_stable_hash_for!(struct Body<'tcx> {
418411 basic_blocks,
419412 source_scopes,
420413 source_scope_local_data,
421- promoted,
422414 yield_ty,
423415 generator_drop,
424416 generator_layout,
@@ -1737,23 +1729,25 @@ pub enum PlaceBase<'tcx> {
17371729}
17381730
17391731/// 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 ) ]
17411733pub struct Static < ' tcx > {
17421734 pub ty : Ty < ' tcx > ,
1743- pub kind : StaticKind ,
1735+ pub kind : StaticKind < ' tcx > ,
1736+ pub def_id : DefId ,
17441737}
17451738
17461739#[ derive(
1747- Clone , PartialEq , Eq , PartialOrd , Ord , Hash , HashStable , RustcEncodable , RustcDecodable ,
1740+ Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , HashStable , RustcEncodable , RustcDecodable ,
17481741) ]
1749- pub enum StaticKind {
1750- Promoted ( Promoted ) ,
1751- Static ( DefId ) ,
1742+ pub enum StaticKind < ' tcx > {
1743+ Promoted ( Promoted , SubstsRef < ' tcx > ) ,
1744+ Static ,
17521745}
17531746
17541747impl_stable_hash_for ! ( struct Static <' tcx> {
17551748 ty,
1756- kind
1749+ kind,
1750+ def_id
17571751} ) ;
17581752
17591753/// The `Projection` data structure defines things of the form `base.x`, `*b` or `b[index]`.
@@ -2114,10 +2108,12 @@ impl Debug for PlaceBase<'_> {
21142108 fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
21152109 match * self {
21162110 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 } ) => {
21182112 write ! ( fmt, "({}: {:?})" , ty:: tls:: with( |tcx| tcx. def_path_str( def_id) ) , ty)
21192113 }
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+ } ) => {
21212117 write ! ( fmt, "({:?}: {:?})" , promoted, ty)
21222118 }
21232119 }
@@ -3032,7 +3028,6 @@ BraceStructTypeFoldableImpl! {
30323028 basic_blocks,
30333029 source_scopes,
30343030 source_scope_local_data,
3035- promoted,
30363031 yield_ty,
30373032 generator_drop,
30383033 generator_layout,
@@ -3226,13 +3221,63 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
32263221impl < ' tcx > TypeFoldable < ' tcx > for Place < ' tcx > {
32273222 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
32283223 Place {
3229- base : self . base . clone ( ) ,
3224+ base : self . base . fold_with ( folder ) ,
32303225 projection : self . projection . fold_with ( folder) ,
32313226 }
32323227 }
32333228
32343229 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+ }
32363281 }
32373282}
32383283
0 commit comments