@@ -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 ;
@@ -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 , u32 ) ,
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
@@ -1974,8 +1975,8 @@ impl<'tcx> Place<'tcx> {
1974
1975
self . elem ( ProjectionElem :: Deref )
1975
1976
}
1976
1977
1977
- pub fn downcast ( self , adt_def : & ' tcx AdtDef , variant_index : usize ) -> Place < ' tcx > {
1978
- self . elem ( ProjectionElem :: Downcast ( adt_def, variant_index as u32 ) )
1978
+ pub fn downcast ( self , adt_def : & ' tcx AdtDef , variant_index : VariantIdx ) -> Place < ' tcx > {
1979
+ self . elem ( ProjectionElem :: Downcast ( adt_def, variant_index) )
1979
1980
}
1980
1981
1981
1982
pub fn index ( self , index : Local ) -> Place < ' tcx > {
@@ -2026,7 +2027,7 @@ impl<'tcx> Debug for Place<'tcx> {
2026
2027
Promoted ( ref promoted) => write ! ( fmt, "({:?}: {:?})" , promoted. 0 , promoted. 1 ) ,
2027
2028
Projection ( ref data) => match data. elem {
2028
2029
ProjectionElem :: Downcast ( ref adt_def, index) => {
2029
- write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index as usize ] . name)
2030
+ write ! ( fmt, "({:?} as {})" , data. base, adt_def. variants[ index] . name)
2030
2031
}
2031
2032
ProjectionElem :: Deref => write ! ( fmt, "(*{:?})" , data. base) ,
2032
2033
ProjectionElem :: Field ( field, ty) => {
@@ -2216,7 +2217,7 @@ pub enum AggregateKind<'tcx> {
2216
2217
/// active field index would identity the field `c`
2217
2218
Adt (
2218
2219
& ' tcx AdtDef ,
2219
- usize ,
2220
+ VariantIdx ,
2220
2221
& ' tcx Substs < ' tcx > ,
2221
2222
Option < UserTypeAnnotation < ' tcx > > ,
2222
2223
Option < usize > ,
0 commit comments