@@ -1223,36 +1223,26 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12231223 // so it's easier to do that here then to wait until we would encounter
12241224 // normally in the visitor walk.
12251225 for variant in adt_def. variants ( ) . iter ( ) {
1226- self . encode_enum_variant_info ( variant) ;
1227- }
1228- }
1229-
1230- fn encode_enum_variant_info ( & mut self , variant : & ty:: VariantDef ) {
1231- let tcx = self . tcx ;
1232- let def_id = variant. def_id ;
1233- debug ! ( "EncodeContext::encode_enum_variant_info({:?})" , def_id) ;
1226+ let data = VariantData {
1227+ discr : variant. discr ,
1228+ ctor : variant. ctor . map ( |( kind, def_id) | ( kind, def_id. index ) ) ,
1229+ is_non_exhaustive : variant. is_field_list_non_exhaustive ( ) ,
1230+ } ;
1231+ record ! ( self . tables. variant_data[ variant. def_id] <- data) ;
12341232
1235- let data = VariantData {
1236- discr : variant. discr ,
1237- ctor : variant . ctor . map ( | ( kind , def_id ) | ( kind , def_id . index ) ) ,
1238- is_non_exhaustive : variant . is_field_list_non_exhaustive ( ) ,
1239- } ;
1233+ self . tables . constness . set ( variant . def_id . index , hir :: Constness :: Const ) ;
1234+ record_array ! ( self . tables . children [ variant . def_id ] <- variant. fields . iter ( ) . map ( |f| {
1235+ assert! ( f . did . is_local ( ) ) ;
1236+ f . did . index
1237+ } ) ) ;
12401238
1241- record ! ( self . tables. variant_data[ def_id] <- data) ;
1242- self . tables . constness . set ( def_id. index , hir:: Constness :: Const ) ;
1243- record_array ! ( self . tables. children[ def_id] <- variant. fields. iter( ) . map( |f| {
1244- assert!( f. did. is_local( ) ) ;
1245- f. did. index
1246- } ) ) ;
1247- if let Some ( ( CtorKind :: Fn , ctor_def_id) ) = variant. ctor {
1248- debug ! ( "EncodeContext::encode_enum_variant_ctor({:?})" , ctor_def_id) ;
1249-
1250- self . tables . constness . set ( ctor_def_id. index , hir:: Constness :: Const ) ;
1251-
1252- let fn_sig = tcx. fn_sig ( ctor_def_id) ;
1253- record ! ( self . tables. fn_sig[ ctor_def_id] <- fn_sig) ;
1254- // FIXME(eddyb) encode signature only for `ctor_def_id`.
1255- record ! ( self . tables. fn_sig[ def_id] <- fn_sig) ;
1239+ if let Some ( ( CtorKind :: Fn , ctor_def_id) ) = variant. ctor {
1240+ self . tables . constness . set ( ctor_def_id. index , hir:: Constness :: Const ) ;
1241+ let fn_sig = tcx. fn_sig ( ctor_def_id) ;
1242+ record ! ( self . tables. fn_sig[ ctor_def_id] <- fn_sig) ;
1243+ // FIXME only encode signature for ctor_def_id
1244+ record ! ( self . tables. fn_sig[ variant. def_id] <- fn_sig) ;
1245+ }
12561246 }
12571247 }
12581248
0 commit comments