@@ -1916,12 +1916,18 @@ pub enum PlaceBase<'tcx> {
1916
1916
1917
1917
/// The `DefId` of a static, along with its normalized type (which is
1918
1918
/// 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 ) ]
1920
1920
pub struct Static < ' tcx > {
1921
1921
pub def_id : DefId ,
1922
1922
pub ty : Ty < ' tcx > ,
1923
1923
}
1924
1924
1925
+ BraceStructTypeFoldableImpl ! {
1926
+ impl <' tcx> TypeFoldable <' tcx> for Static <' tcx> {
1927
+ def_id, ty
1928
+ }
1929
+ }
1930
+
1925
1931
impl_stable_hash_for ! ( struct Static <' tcx> {
1926
1932
def_id,
1927
1933
ty
@@ -2046,24 +2052,32 @@ impl<'tcx> Place<'tcx> {
2046
2052
}
2047
2053
}
2048
2054
2049
- impl < ' tcx > Debug for Place < ' tcx > {
2055
+ impl < ' tcx > Debug for PlaceBase < ' tcx > {
2050
2056
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
2051
- use self :: Place :: * ;
2052
-
2053
2057
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 ! (
2056
2060
fmt,
2057
2061
"({}: {:?})" ,
2058
2062
ty:: tls:: with( |tcx| tcx. item_path_str( def_id) ) ,
2059
2063
ty
2060
2064
) ,
2061
- Base ( PlaceBase :: Promoted ( ref promoted) ) => write ! (
2065
+ PlaceBase :: Promoted ( ref promoted) => write ! (
2062
2066
fmt,
2063
2067
"({:?}: {:?})" ,
2064
2068
promoted. 0 ,
2065
2069
promoted. 1
2066
2070
) ,
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) ,
2067
2081
Projection ( ref data) => match data. elem {
2068
2082
ProjectionElem :: Downcast ( ref adt_def, index) => {
2069
2083
write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index] . ident)
@@ -3302,23 +3316,18 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
3302
3316
}
3303
3317
}
3304
3318
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) ,
3314
3323
}
3324
+ }
3315
3325
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) ,
3322
3331
}
3323
3332
}
3324
3333
@@ -3443,8 +3452,6 @@ where
3443
3452
}
3444
3453
}
3445
3454
3446
- CloneTypeFoldableImpls ! { Field , }
3447
-
3448
3455
BraceStructTypeFoldableImpl ! {
3449
3456
impl <' tcx> TypeFoldable <' tcx> for Constant <' tcx> {
3450
3457
span, ty, user_ty, literal
0 commit comments