@@ -40,6 +40,7 @@ use syntax_pos::{Span, DUMMY_SP};
40
40
use ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
41
41
use ty:: subst:: { CanonicalUserSubsts , Subst , Substs } ;
42
42
use ty:: { self , AdtDef , CanonicalTy , ClosureSubsts , GeneratorSubsts , Region , Ty , TyCtxt } ;
43
+ use ty:: layout:: VariantIdx ;
43
44
use util:: ppaux;
44
45
45
46
pub use mir:: interpret:: AssertMessage ;
@@ -1753,7 +1754,7 @@ pub enum StatementKind<'tcx> {
1753
1754
/// Write the discriminant for a variant to the enum Place.
1754
1755
SetDiscriminant {
1755
1756
place : Place < ' tcx > ,
1756
- variant_index : usize ,
1757
+ variant_index : VariantIdx ,
1757
1758
} ,
1758
1759
1759
1760
/// Start a live range for the storage of the local.
@@ -1939,7 +1940,7 @@ pub enum ProjectionElem<'tcx, V, T> {
1939
1940
/// "Downcast" to a variant of an ADT. Currently, we only introduce
1940
1941
/// this for ADTs with more than one variant. It may be better to
1941
1942
/// just introduce it always, or always for enums.
1942
- Downcast ( & ' tcx AdtDef , usize ) ,
1943
+ Downcast ( & ' tcx AdtDef , VariantIdx ) ,
1943
1944
}
1944
1945
1945
1946
/// 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>>;
1950
1951
/// and the index is a local.
1951
1952
pub type PlaceElem < ' tcx > = ProjectionElem < ' tcx , Local , Ty < ' tcx > > ;
1952
1953
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
+
1953
1959
/// Alias for projections as they appear in `UserTypeProjection`, where we
1954
1960
/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
1955
1961
pub type ProjectionKind < ' tcx > = ProjectionElem < ' tcx , ( ) , ( ) > ;
@@ -1969,7 +1975,7 @@ impl<'tcx> Place<'tcx> {
1969
1975
self . elem ( ProjectionElem :: Deref )
1970
1976
}
1971
1977
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 > {
1973
1979
self . elem ( ProjectionElem :: Downcast ( adt_def, variant_index) )
1974
1980
}
1975
1981
@@ -2211,7 +2217,7 @@ pub enum AggregateKind<'tcx> {
2211
2217
/// active field index would identity the field `c`
2212
2218
Adt (
2213
2219
& ' tcx AdtDef ,
2214
- usize ,
2220
+ VariantIdx ,
2215
2221
& ' tcx Substs < ' tcx > ,
2216
2222
Option < UserTypeAnnotation < ' tcx > > ,
2217
2223
Option < usize > ,
0 commit comments