@@ -40,6 +40,7 @@ use syntax_pos::{Span, DUMMY_SP};
4040use ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
4141use ty:: subst:: { CanonicalUserSubsts , Subst , Substs } ;
4242use ty:: { self , AdtDef , CanonicalTy , ClosureSubsts , GeneratorSubsts , Region , Ty , TyCtxt } ;
43+ use ty:: layout:: VariantIdx ;
4344use util:: ppaux;
4445
4546pub use mir:: interpret:: AssertMessage ;
@@ -1753,7 +1754,7 @@ pub enum StatementKind<'tcx> {
17531754 /// Write the discriminant for a variant to the enum Place.
17541755 SetDiscriminant {
17551756 place : Place < ' tcx > ,
1756- variant_index : usize ,
1757+ variant_index : VariantIdx ,
17571758 } ,
17581759
17591760 /// Start a live range for the storage of the local.
@@ -1939,7 +1940,7 @@ pub enum ProjectionElem<'tcx, V, T> {
19391940 /// "Downcast" to a variant of an ADT. Currently, we only introduce
19401941 /// this for ADTs with more than one variant. It may be better to
19411942 /// just introduce it always, or always for enums.
1942- Downcast ( & ' tcx AdtDef , usize ) ,
1943+ Downcast ( & ' tcx AdtDef , VariantIdx ) ,
19431944}
19441945
19451946/// Alias for projections as they appear in places, where the base is a place
@@ -1950,6 +1951,11 @@ pub type PlaceProjection<'tcx> = Projection<'tcx, Place<'tcx>, Local, Ty<'tcx>>;
19501951/// and the index is a local.
19511952pub type PlaceElem < ' tcx > = ProjectionElem < ' tcx , Local , Ty < ' tcx > > ;
19521953
1954+ // at least on 64 bit systems, `PlaceElem` should not be larger than two pointers
1955+ static_assert ! ( PROJECTION_ELEM_IS_2_PTRS_LARGE :
1956+ mem:: size_of:: <PlaceElem <' _>>( ) <= 16
1957+ ) ;
1958+
19531959/// Alias for projections as they appear in `UserTypeProjection`, where we
19541960/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
19551961pub type ProjectionKind < ' tcx > = ProjectionElem < ' tcx , ( ) , ( ) > ;
@@ -1969,7 +1975,7 @@ impl<'tcx> Place<'tcx> {
19691975 self . elem ( ProjectionElem :: Deref )
19701976 }
19711977
1972- pub fn downcast ( self , adt_def : & ' tcx AdtDef , variant_index : usize ) -> Place < ' tcx > {
1978+ pub fn downcast ( self , adt_def : & ' tcx AdtDef , variant_index : VariantIdx ) -> Place < ' tcx > {
19731979 self . elem ( ProjectionElem :: Downcast ( adt_def, variant_index) )
19741980 }
19751981
@@ -2211,7 +2217,7 @@ pub enum AggregateKind<'tcx> {
22112217 /// active field index would identity the field `c`
22122218 Adt (
22132219 & ' tcx AdtDef ,
2214- usize ,
2220+ VariantIdx ,
22152221 & ' tcx Substs < ' tcx > ,
22162222 Option < UserTypeAnnotation < ' tcx > > ,
22172223 Option < usize > ,
0 commit comments