@@ -1701,6 +1701,9 @@ pub enum Place<'tcx> {
1701
1701
/// static or static mut variable
1702
1702
Static ( Box < Static < ' tcx > > ) ,
1703
1703
1704
+ /// Constant code promoted to an injected static
1705
+ Promoted ( Box < ( Promoted , Ty < ' tcx > ) > ) ,
1706
+
1704
1707
/// projection out of a place (access a field, deref a pointer, etc)
1705
1708
Projection ( Box < PlaceProjection < ' tcx > > ) ,
1706
1709
}
@@ -1810,6 +1813,7 @@ impl<'tcx> Debug for Place<'tcx> {
1810
1813
ty:: tls:: with( |tcx| tcx. item_path_str( def_id) ) ,
1811
1814
ty
1812
1815
) ,
1816
+ Promoted ( ref promoted) => write ! ( fmt, "({:?}: {:?})" , promoted. 0 , promoted. 1 ) ,
1813
1817
Projection ( ref data) => match data. elem {
1814
1818
ProjectionElem :: Downcast ( ref adt_def, index) => {
1815
1819
write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index] . name)
@@ -1910,9 +1914,7 @@ impl<'tcx> Operand<'tcx> {
1910
1914
Operand :: Constant ( box Constant {
1911
1915
span,
1912
1916
ty,
1913
- literal : Literal :: Value {
1914
- value : ty:: Const :: zero_sized ( tcx, ty) ,
1915
- } ,
1917
+ literal : ty:: Const :: zero_sized ( tcx, ty) ,
1916
1918
} )
1917
1919
}
1918
1920
@@ -2200,38 +2202,15 @@ impl<'tcx> Debug for Rvalue<'tcx> {
2200
2202
pub struct Constant < ' tcx > {
2201
2203
pub span : Span ,
2202
2204
pub ty : Ty < ' tcx > ,
2203
- pub literal : Literal < ' tcx > ,
2205
+ pub literal : & ' tcx ty :: Const < ' tcx > ,
2204
2206
}
2205
2207
2206
2208
newtype_index ! ( Promoted { DEBUG_FORMAT = "promoted[{}]" } ) ;
2207
2209
2208
- #[ derive( Clone , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
2209
- pub enum Literal < ' tcx > {
2210
- Value {
2211
- value : & ' tcx ty:: Const < ' tcx > ,
2212
- } ,
2213
- Promoted {
2214
- // Index into the `promoted` vector of `Mir`.
2215
- index : Promoted ,
2216
- } ,
2217
- }
2218
-
2219
2210
impl < ' tcx > Debug for Constant < ' tcx > {
2220
2211
fn fmt ( & self , fmt : & mut Formatter ) -> fmt:: Result {
2221
- write ! ( fmt, "{:?}" , self . literal)
2222
- }
2223
- }
2224
-
2225
- impl < ' tcx > Debug for Literal < ' tcx > {
2226
- fn fmt ( & self , fmt : & mut Formatter ) -> fmt:: Result {
2227
- use self :: Literal :: * ;
2228
- match * self {
2229
- Value { value } => {
2230
- write ! ( fmt, "const " ) ?;
2231
- fmt_const_val ( fmt, value)
2232
- }
2233
- Promoted { index } => write ! ( fmt, "{:?}" , index) ,
2234
- }
2212
+ write ! ( fmt, "const " ) ?;
2213
+ fmt_const_val ( fmt, self . literal )
2235
2214
}
2236
2215
}
2237
2216
@@ -2918,20 +2897,3 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
2918
2897
self . ty . visit_with ( visitor) || self . literal . visit_with ( visitor)
2919
2898
}
2920
2899
}
2921
-
2922
- impl < ' tcx > TypeFoldable < ' tcx > for Literal < ' tcx > {
2923
- fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
2924
- match * self {
2925
- Literal :: Value { value } => Literal :: Value {
2926
- value : value. fold_with ( folder) ,
2927
- } ,
2928
- Literal :: Promoted { index } => Literal :: Promoted { index } ,
2929
- }
2930
- }
2931
- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
2932
- match * self {
2933
- Literal :: Value { value } => value. visit_with ( visitor) ,
2934
- Literal :: Promoted { .. } => false ,
2935
- }
2936
- }
2937
- }
0 commit comments