@@ -1701,6 +1701,9 @@ pub enum Place<'tcx> {
17011701 /// static or static mut variable
17021702 Static ( Box < Static < ' tcx > > ) ,
17031703
1704+ /// Constant code promoted to an injected static
1705+ Promoted ( Box < ( Promoted , Ty < ' tcx > ) > ) ,
1706+
17041707 /// projection out of a place (access a field, deref a pointer, etc)
17051708 Projection ( Box < PlaceProjection < ' tcx > > ) ,
17061709}
@@ -1810,6 +1813,7 @@ impl<'tcx> Debug for Place<'tcx> {
18101813 ty:: tls:: with( |tcx| tcx. item_path_str( def_id) ) ,
18111814 ty
18121815 ) ,
1816+ Promoted ( ref promoted) => write ! ( fmt, "({:?}: {:?})" , promoted. 0 , promoted. 1 ) ,
18131817 Projection ( ref data) => match data. elem {
18141818 ProjectionElem :: Downcast ( ref adt_def, index) => {
18151819 write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index] . name)
@@ -1910,9 +1914,7 @@ impl<'tcx> Operand<'tcx> {
19101914 Operand :: Constant ( box Constant {
19111915 span,
19121916 ty,
1913- literal : Literal :: Value {
1914- value : ty:: Const :: zero_sized ( tcx, ty) ,
1915- } ,
1917+ literal : ty:: Const :: zero_sized ( tcx, ty) ,
19161918 } )
19171919 }
19181920
@@ -2200,38 +2202,15 @@ impl<'tcx> Debug for Rvalue<'tcx> {
22002202pub struct Constant < ' tcx > {
22012203 pub span : Span ,
22022204 pub ty : Ty < ' tcx > ,
2203- pub literal : Literal < ' tcx > ,
2205+ pub literal : & ' tcx ty :: Const < ' tcx > ,
22042206}
22052207
22062208newtype_index ! ( Promoted { DEBUG_FORMAT = "promoted[{}]" } ) ;
22072209
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-
22192210impl < ' tcx > Debug for Constant < ' tcx > {
22202211 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 )
22352214 }
22362215}
22372216
@@ -2918,20 +2897,3 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
29182897 self . ty . visit_with ( visitor) || self . literal . visit_with ( visitor)
29192898 }
29202899}
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