@@ -1181,6 +1181,21 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11811181 if should_encode_type ( tcx, local_id, def_kind) {
11821182 record ! ( self . tables. type_of[ def_id] <- self . tcx. type_of( def_id) ) ;
11831183 }
1184+ if let DefKind :: Fn | DefKind :: AssocFn = def_kind {
1185+ self . tables . asyncness . set ( def_id. index , tcx. asyncness ( def_id) ) ;
1186+ record_array ! ( self . tables. fn_arg_names[ def_id] <- tcx. fn_arg_names( def_id) ) ;
1187+ let constness = if self . tcx . is_const_fn_raw ( def_id) {
1188+ hir:: Constness :: Const
1189+ } else {
1190+ hir:: Constness :: NotConst
1191+ } ;
1192+ self . tables . constness . set ( def_id. index , constness) ;
1193+
1194+ record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1195+ if tcx. is_intrinsic ( def_id) {
1196+ self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
1197+ }
1198+ }
11841199 if let DefKind :: TyParam = def_kind {
11851200 let default = self . tcx . object_lifetime_default ( def_id) ;
11861201 record ! ( self . tables. object_lifetime_default[ def_id] <- default ) ;
@@ -1342,54 +1357,24 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13421357 self . tables . assoc_container . set ( def_id. index , trait_item. container ) ;
13431358
13441359 match trait_item. kind {
1345- ty:: AssocKind :: Const => { }
1346- ty:: AssocKind :: Fn => {
1347- record_array ! ( self . tables. fn_arg_names[ def_id] <- tcx. fn_arg_names( def_id) ) ;
1348- self . tables . asyncness . set ( def_id. index , tcx. asyncness ( def_id) ) ;
1349- self . tables . constness . set ( def_id. index , hir:: Constness :: NotConst ) ;
1350- }
1360+ ty:: AssocKind :: Const | ty:: AssocKind :: Fn => { }
13511361 ty:: AssocKind :: Type => {
13521362 self . encode_explicit_item_bounds ( def_id) ;
13531363 }
13541364 }
1355- if trait_item. kind == ty:: AssocKind :: Fn {
1356- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1357- }
13581365 }
13591366
13601367 fn encode_info_for_impl_item ( & mut self , def_id : DefId ) {
13611368 debug ! ( "EncodeContext::encode_info_for_impl_item({:?})" , def_id) ;
1362- let tcx = self . tcx ;
13631369
13641370 let ast_item = self . tcx . hir ( ) . expect_impl_item ( def_id. expect_local ( ) ) ;
13651371 self . tables . impl_defaultness . set ( def_id. index , ast_item. defaultness ) ;
13661372 let impl_item = self . tcx . associated_item ( def_id) ;
13671373 self . tables . assoc_container . set ( def_id. index , impl_item. container ) ;
13681374
1369- match impl_item. kind {
1370- ty:: AssocKind :: Fn => {
1371- let hir:: ImplItemKind :: Fn ( ref sig, body) = ast_item. kind else { bug ! ( ) } ;
1372- self . tables . asyncness . set ( def_id. index , sig. header . asyncness ) ;
1373- record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1374- // Can be inside `impl const Trait`, so using sig.header.constness is not reliable
1375- let constness = if self . tcx . is_const_fn_raw ( def_id) {
1376- hir:: Constness :: Const
1377- } else {
1378- hir:: Constness :: NotConst
1379- } ;
1380- self . tables . constness . set ( def_id. index , constness) ;
1381- }
1382- ty:: AssocKind :: Const | ty:: AssocKind :: Type => { }
1383- }
13841375 if let Some ( trait_item_def_id) = impl_item. trait_item_def_id {
13851376 self . tables . trait_item_def_id . set ( def_id. index , trait_item_def_id. into ( ) ) ;
13861377 }
1387- if impl_item. kind == ty:: AssocKind :: Fn {
1388- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1389- if tcx. is_intrinsic ( def_id) {
1390- self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
1391- }
1392- }
13931378 }
13941379
13951380 fn encode_mir ( & mut self ) {
@@ -1512,11 +1497,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15121497 debug ! ( "EncodeContext::encode_info_for_item({:?})" , def_id) ;
15131498
15141499 match item. kind {
1515- hir:: ItemKind :: Fn ( ref sig, .., body) => {
1516- self . tables . asyncness . set ( def_id. index , sig. header . asyncness ) ;
1517- record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1518- self . tables . constness . set ( def_id. index , sig. header . constness ) ;
1519- }
15201500 hir:: ItemKind :: Macro ( ref macro_def, _) => {
15211501 if macro_def. macro_rules {
15221502 self . tables . is_macro_rules . set_nullable ( def_id. index , true ) ;
@@ -1599,6 +1579,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15991579 | hir:: ItemKind :: Const ( ..)
16001580 | hir:: ItemKind :: ForeignMod { .. }
16011581 | hir:: ItemKind :: GlobalAsm ( ..)
1582+ | hir:: ItemKind :: Fn ( ..)
16021583 | hir:: ItemKind :: TyAlias ( ..) => { }
16031584 } ;
16041585 // FIXME(eddyb) there should be a nicer way to do this.
@@ -1633,12 +1614,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16331614 }
16341615 _ => { }
16351616 }
1636- if let hir:: ItemKind :: Fn ( ..) = item. kind {
1637- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1638- if tcx. is_intrinsic ( def_id) {
1639- self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
1640- }
1641- }
16421617 if let hir:: ItemKind :: Impl { .. } = item. kind {
16431618 if let Some ( trait_ref) = self . tcx . impl_trait_ref ( def_id) {
16441619 record ! ( self . tables. impl_trait_ref[ def_id] <- trait_ref) ;
@@ -2016,32 +1991,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20161991 }
20171992 LazyArray :: empty ( )
20181993 }
2019-
2020- fn encode_info_for_foreign_item ( & mut self , def_id : DefId , nitem : & hir:: ForeignItem < ' _ > ) {
2021- let tcx = self . tcx ;
2022-
2023- debug ! ( "EncodeContext::encode_info_for_foreign_item({:?})" , def_id) ;
2024-
2025- match nitem. kind {
2026- hir:: ForeignItemKind :: Fn ( _, ref names, _) => {
2027- self . tables . asyncness . set ( def_id. index , hir:: IsAsync :: NotAsync ) ;
2028- record_array ! ( self . tables. fn_arg_names[ def_id] <- * names) ;
2029- let constness = if self . tcx . is_const_fn_raw ( def_id) {
2030- hir:: Constness :: Const
2031- } else {
2032- hir:: Constness :: NotConst
2033- } ;
2034- self . tables . constness . set ( def_id. index , constness) ;
2035- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
2036- }
2037- hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => { }
2038- }
2039- if let hir:: ForeignItemKind :: Fn ( ..) = nitem. kind {
2040- if tcx. is_intrinsic ( def_id) {
2041- self . tables . is_intrinsic . set_nullable ( def_id. index , true ) ;
2042- }
2043- }
2044- }
20451994}
20461995
20471996// FIXME(eddyb) make metadata encoding walk over all definitions, instead of HIR.
@@ -2062,10 +2011,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EncodeContext<'a, 'tcx> {
20622011 _ => self . encode_info_for_item ( item. owner_id . to_def_id ( ) , item) ,
20632012 }
20642013 }
2065- fn visit_foreign_item ( & mut self , ni : & ' tcx hir:: ForeignItem < ' tcx > ) {
2066- intravisit:: walk_foreign_item ( self , ni) ;
2067- self . encode_info_for_foreign_item ( ni. owner_id . to_def_id ( ) , ni) ;
2068- }
20692014 fn visit_generics ( & mut self , generics : & ' tcx hir:: Generics < ' tcx > ) {
20702015 intravisit:: walk_generics ( self , generics) ;
20712016 self . encode_info_for_generics ( generics) ;
0 commit comments