@@ -1939,7 +1939,7 @@ pub enum ProjectionElem<'tcx, V, T> {
19391939 /// "Downcast" to a variant of an ADT. Currently, we only introduce
19401940 /// this for ADTs with more than one variant. It may be better to
19411941 /// just introduce it always, or always for enums.
1942- Downcast ( & ' tcx AdtDef , usize ) ,
1942+ Downcast ( & ' tcx AdtDef , u32 ) ,
19431943}
19441944
19451945/// Alias for projections as they appear in places, where the base is a place
@@ -1950,6 +1950,11 @@ pub type PlaceProjection<'tcx> = Projection<'tcx, Place<'tcx>, Local, Ty<'tcx>>;
19501950/// and the index is a local.
19511951pub type PlaceElem < ' tcx > = ProjectionElem < ' tcx , Local , Ty < ' tcx > > ;
19521952
1953+ // at least on 64 bit systems, `PlaceElem` should not be larger than two pointers
1954+ static_assert ! ( PROJECTION_ELEM_IS_2_PTRS_LARGE :
1955+ mem:: size_of:: <PlaceElem <' _>>( ) <= 16
1956+ ) ;
1957+
19531958/// Alias for projections as they appear in `UserTypeProjection`, where we
19541959/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
19551960pub type ProjectionKind < ' tcx > = ProjectionElem < ' tcx , ( ) , ( ) > ;
@@ -1970,7 +1975,7 @@ impl<'tcx> Place<'tcx> {
19701975 }
19711976
19721977 pub fn downcast ( self , adt_def : & ' tcx AdtDef , variant_index : usize ) -> Place < ' tcx > {
1973- self . elem ( ProjectionElem :: Downcast ( adt_def, variant_index) )
1978+ self . elem ( ProjectionElem :: Downcast ( adt_def, variant_index as u32 ) )
19741979 }
19751980
19761981 pub fn index ( self , index : Local ) -> Place < ' tcx > {
@@ -2021,7 +2026,7 @@ impl<'tcx> Debug for Place<'tcx> {
20212026 Promoted ( ref promoted) => write ! ( fmt, "({:?}: {:?})" , promoted. 0 , promoted. 1 ) ,
20222027 Projection ( ref data) => match data. elem {
20232028 ProjectionElem :: Downcast ( ref adt_def, index) => {
2024- write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index] . name)
2029+ write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index as usize ] . name)
20252030 }
20262031 ProjectionElem :: Deref => write ! ( fmt, "(*{:?})" , data. base) ,
20272032 ProjectionElem :: Field ( field, ty) => {
0 commit comments