@@ -1031,14 +1031,16 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
10311031 fn aggregate_field_ty (
10321032 & mut self ,
10331033 ak : & Box < AggregateKind < ' tcx > > ,
1034- field : usize ,
1034+ field_index : usize ,
10351035 location : Location ,
10361036 ) -> Result < Ty < ' tcx > , FieldAccessError > {
10371037 let tcx = self . tcx ( ) ;
10381038
10391039 match * * ak {
1040- AggregateKind :: Adt ( def, variant, substs, _) => {
1041- if let Some ( field) = def. variants [ variant] . fields . get ( field) {
1040+ AggregateKind :: Adt ( def, variant_index, substs, active_field_index) => {
1041+ let variant = & def. variants [ variant_index] ;
1042+ let adj_field_index = active_field_index. unwrap_or ( field_index) ;
1043+ if let Some ( field) = variant. fields . get ( adj_field_index) {
10421044 Ok ( self . normalize ( & field. ty ( tcx, substs) , location) )
10431045 } else {
10441046 Err ( FieldAccessError :: OutOfRange {
@@ -1047,18 +1049,18 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
10471049 }
10481050 }
10491051 AggregateKind :: Closure ( def_id, substs) => {
1050- match substs. upvar_tys ( def_id, tcx) . nth ( field ) {
1052+ match substs. upvar_tys ( def_id, tcx) . nth ( field_index ) {
10511053 Some ( ty) => Ok ( ty) ,
10521054 None => Err ( FieldAccessError :: OutOfRange {
10531055 field_count : substs. upvar_tys ( def_id, tcx) . count ( ) ,
10541056 } ) ,
10551057 }
10561058 }
10571059 AggregateKind :: Generator ( def_id, substs, _) => {
1058- if let Some ( ty) = substs. upvar_tys ( def_id, tcx) . nth ( field ) {
1059- Ok ( ty) ;
1060+ if let Some ( ty) = substs. upvar_tys ( def_id, tcx) . nth ( field_index ) {
1061+ Ok ( ty)
10601062 } else {
1061- match substs. field_tys ( def_id, tcx) . nth ( field ) {
1063+ match substs. field_tys ( def_id, tcx) . nth ( field_index ) {
10621064 Some ( ty) => Ok ( ty) ,
10631065 None => Err ( FieldAccessError :: OutOfRange {
10641066 field_count : substs. field_tys ( def_id, tcx) . count ( ) + 1 ,
0 commit comments