@@ -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 ;
@@ -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 , u32 ) ,
1943+ Downcast ( & ' tcx AdtDef , VariantIdx ) ,
19431944}
19441945
19451946/// Alias for projections as they appear in places, where the base is a place
@@ -1974,8 +1975,8 @@ impl<'tcx> Place<'tcx> {
19741975 self . elem ( ProjectionElem :: Deref )
19751976 }
19761977
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) )
19791980 }
19801981
19811982 pub fn index ( self , index : Local ) -> Place < ' tcx > {
@@ -2026,7 +2027,7 @@ impl<'tcx> Debug for Place<'tcx> {
20262027 Promoted ( ref promoted) => write ! ( fmt, "({:?}: {:?})" , promoted. 0 , promoted. 1 ) ,
20272028 Projection ( ref data) => match data. elem {
20282029 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)
20302031 }
20312032 ProjectionElem :: Deref => write ! ( fmt, "(*{:?})" , data. base) ,
20322033 ProjectionElem :: Field ( field, ty) => {
@@ -2216,7 +2217,7 @@ pub enum AggregateKind<'tcx> {
22162217 /// active field index would identity the field `c`
22172218 Adt (
22182219 & ' tcx AdtDef ,
2219- usize ,
2220+ VariantIdx ,
22202221 & ' tcx Substs < ' tcx > ,
22212222 Option < UserTypeAnnotation < ' tcx > > ,
22222223 Option < usize > ,
0 commit comments