@@ -1916,12 +1916,18 @@ pub enum PlaceBase<'tcx> {
19161916
19171917/// The `DefId` of a static, along with its normalized type (which is
19181918/// stored to avoid requiring normalization when reading MIR).
1919- #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
1919+ #[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
19201920pub struct Static < ' tcx > {
19211921 pub def_id : DefId ,
19221922 pub ty : Ty < ' tcx > ,
19231923}
19241924
1925+ BraceStructTypeFoldableImpl ! {
1926+ impl <' tcx> TypeFoldable <' tcx> for Static <' tcx> {
1927+ def_id, ty
1928+ }
1929+ }
1930+
19251931impl_stable_hash_for ! ( struct Static <' tcx> {
19261932 def_id,
19271933 ty
@@ -2046,24 +2052,32 @@ impl<'tcx> Place<'tcx> {
20462052 }
20472053}
20482054
2049- impl < ' tcx > Debug for Place < ' tcx > {
2055+ impl < ' tcx > Debug for PlaceBase < ' tcx > {
20502056 fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
2051- use self :: Place :: * ;
2052-
20532057 match * self {
2054- Base ( PlaceBase :: Local ( id) ) => write ! ( fmt, "{:?}" , id) ,
2055- Base ( PlaceBase :: Static ( box self :: Static { def_id, ty } ) ) => write ! (
2058+ PlaceBase :: Local ( id) => write ! ( fmt, "{:?}" , id) ,
2059+ PlaceBase :: Static ( box self :: Static { def_id, ty } ) => write ! (
20562060 fmt,
20572061 "({}: {:?})" ,
20582062 ty:: tls:: with( |tcx| tcx. item_path_str( def_id) ) ,
20592063 ty
20602064 ) ,
2061- Base ( PlaceBase :: Promoted ( ref promoted) ) => write ! (
2065+ PlaceBase :: Promoted ( ref promoted) => write ! (
20622066 fmt,
20632067 "({:?}: {:?})" ,
20642068 promoted. 0 ,
20652069 promoted. 1
20662070 ) ,
2071+ }
2072+ }
2073+ }
2074+
2075+ impl < ' tcx > Debug for Place < ' tcx > {
2076+ fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
2077+ use self :: Place :: * ;
2078+
2079+ match * self {
2080+ Base ( ref base) => Debug :: fmt ( base, fmt) ,
20672081 Projection ( ref data) => match data. elem {
20682082 ProjectionElem :: Downcast ( ref adt_def, index) => {
20692083 write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index] . ident)
@@ -3302,23 +3316,18 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
33023316 }
33033317}
33043318
3305- impl < ' tcx > TypeFoldable < ' tcx > for Place < ' tcx > {
3306- // TODO: this doesn't look correct!
3307- fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F )
3308- -> Result < Self , F :: Error >
3309- {
3310- match self {
3311- & Place :: Projection ( ref p) => Ok ( Place :: Projection ( p. fold_with ( folder) ?) ) ,
3312- _ => Ok ( self . clone ( ) ) ,
3313- }
3319+ EnumTypeFoldableImpl ! {
3320+ impl <' tcx> TypeFoldable <' tcx> for Place <' tcx> {
3321+ ( Place :: Base ) ( base) ,
3322+ ( Place :: Projection ) ( projection) ,
33143323 }
3324+ }
33153325
3316- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> Result < ( ) , V :: Error > {
3317- if let & Place :: Projection ( ref p) = self {
3318- p. visit_with ( visitor)
3319- } else {
3320- Ok ( ( ) )
3321- }
3326+ EnumTypeFoldableImpl ! {
3327+ impl <' tcx> TypeFoldable <' tcx> for PlaceBase <' tcx> {
3328+ ( PlaceBase :: Local ) ( local) ,
3329+ ( PlaceBase :: Static ) ( statik) ,
3330+ ( PlaceBase :: Promoted ) ( promoted) ,
33223331 }
33233332}
33243333
@@ -3443,8 +3452,6 @@ where
34433452 }
34443453}
34453454
3446- CloneTypeFoldableImpls ! { Field , }
3447-
34483455BraceStructTypeFoldableImpl ! {
34493456 impl <' tcx> TypeFoldable <' tcx> for Constant <' tcx> {
34503457 span, ty, user_ty, literal
0 commit comments