@@ -1315,6 +1315,19 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13151315 if should_encode_type ( tcx, local_id, def_kind) {
13161316 record ! ( self . tables. type_of[ def_id] <- self . tcx. type_of( def_id) ) ;
13171317 }
1318+ if let DefKind :: Fn | DefKind :: AssocFn = def_kind {
1319+ self . tables . asyncness . set_some ( def_id. index , tcx. asyncness ( def_id) ) ;
1320+ record_array ! ( self . tables. fn_arg_names[ def_id] <- tcx. fn_arg_names( def_id) ) ;
1321+ let constness = if self . tcx . is_const_fn_raw ( def_id) {
1322+ hir:: Constness :: Const
1323+ } else {
1324+ hir:: Constness :: NotConst
1325+ } ;
1326+ self . tables . constness . set_some ( def_id. index , constness) ;
1327+
1328+ record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1329+ self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
1330+ }
13181331 if let DefKind :: TyParam = def_kind {
13191332 let default = self . tcx . object_lifetime_default ( def_id) ;
13201333 record ! ( self . tables. object_lifetime_default[ def_id] <- default ) ;
@@ -1446,19 +1459,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14461459 self . tables . assoc_container . set_some ( def_id. index , trait_item. container ) ;
14471460
14481461 match trait_item. kind {
1449- ty:: AssocKind :: Const => { }
1450- ty:: AssocKind :: Fn => {
1451- record_array ! ( self . tables. fn_arg_names[ def_id] <- tcx. fn_arg_names( def_id) ) ;
1452- self . tables . asyncness . set_some ( def_id. index , tcx. asyncness ( def_id) ) ;
1453- self . tables . constness . set_some ( def_id. index , hir:: Constness :: NotConst ) ;
1454- }
1462+ ty:: AssocKind :: Const | ty:: AssocKind :: Fn => { }
14551463 ty:: AssocKind :: Type => {
14561464 self . encode_explicit_item_bounds ( def_id) ;
14571465 }
14581466 }
1459- if trait_item. kind == ty:: AssocKind :: Fn {
1460- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1461- }
14621467 if let Some ( rpitit_info) = trait_item. opt_rpitit_info {
14631468 let rpitit_info = self . lazy ( rpitit_info) ;
14641469 self . tables . opt_rpitit_info . set_some ( def_id. index , rpitit_info) ;
@@ -1467,36 +1472,15 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14671472
14681473 fn encode_info_for_impl_item ( & mut self , def_id : DefId ) {
14691474 debug ! ( "EncodeContext::encode_info_for_impl_item({:?})" , def_id) ;
1470- let tcx = self . tcx ;
14711475
14721476 let defaultness = self . tcx . defaultness ( def_id. expect_local ( ) ) ;
14731477 self . tables . defaultness . set_some ( def_id. index , defaultness) ;
14741478 let impl_item = self . tcx . associated_item ( def_id) ;
14751479 self . tables . assoc_container . set_some ( def_id. index , impl_item. container ) ;
14761480
1477- match impl_item. kind {
1478- ty:: AssocKind :: Fn => {
1479- let ( sig, body) =
1480- self . tcx . hir ( ) . expect_impl_item ( def_id. expect_local ( ) ) . expect_fn ( ) ;
1481- self . tables . asyncness . set_some ( def_id. index , sig. header . asyncness ) ;
1482- record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1483- // Can be inside `impl const Trait`, so using sig.header.constness is not reliable
1484- let constness = if self . tcx . is_const_fn_raw ( def_id) {
1485- hir:: Constness :: Const
1486- } else {
1487- hir:: Constness :: NotConst
1488- } ;
1489- self . tables . constness . set_some ( def_id. index , constness) ;
1490- }
1491- ty:: AssocKind :: Const | ty:: AssocKind :: Type => { }
1492- }
14931481 if let Some ( trait_item_def_id) = impl_item. trait_item_def_id {
14941482 self . tables . trait_item_def_id . set_some ( def_id. index , trait_item_def_id. into ( ) ) ;
14951483 }
1496- if impl_item. kind == ty:: AssocKind :: Fn {
1497- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1498- self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
1499- }
15001484 if let Some ( rpitit_info) = impl_item. opt_rpitit_info {
15011485 let rpitit_info = self . lazy ( rpitit_info) ;
15021486 self . tables . opt_rpitit_info . set_some ( def_id. index , rpitit_info) ;
@@ -1624,7 +1608,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16241608 }
16251609
16261610 fn encode_info_for_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1627- let tcx = self . tcx ;
16281611 let def_id = item. owner_id . to_def_id ( ) ;
16291612 debug ! ( "EncodeContext::encode_info_for_item({:?})" , def_id) ;
16301613
@@ -1636,13 +1619,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16361619 } ;
16371620
16381621 match item. kind {
1639- hir:: ItemKind :: Fn ( ref sig, .., body) => {
1640- self . tables . asyncness . set_some ( def_id. index , sig. header . asyncness ) ;
1641- record_array ! ( self . tables. fn_arg_names[ def_id] <- self . tcx. hir( ) . body_param_names( body) ) ;
1642- self . tables . constness . set_some ( def_id. index , sig. header . constness ) ;
1643- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1644- self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
1645- }
16461622 hir:: ItemKind :: Macro ( ref macro_def, _) => {
16471623 self . tables . is_macro_rules . set ( def_id. index , macro_def. macro_rules ) ;
16481624 record ! ( self . tables. macro_definition[ def_id] <- & * macro_def. body) ;
@@ -1691,7 +1667,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16911667 hir:: ItemKind :: Trait ( ..) => {
16921668 record ! ( self . tables. trait_def[ def_id] <- self . tcx. trait_def( def_id) ) ;
16931669
1694- let module_children = tcx. module_children_local ( item. owner_id . def_id ) ;
1670+ let module_children = self . tcx . module_children_local ( item. owner_id . def_id ) ;
16951671 record_array ! ( self . tables. module_children_non_reexports[ def_id] <-
16961672 module_children. iter( ) . map( |child| child. res. def_id( ) . index) ) ;
16971673
@@ -1713,6 +1689,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17131689 | hir:: ItemKind :: Union ( ..)
17141690 | hir:: ItemKind :: ForeignMod { .. }
17151691 | hir:: ItemKind :: GlobalAsm ( ..)
1692+ | hir:: ItemKind :: Fn ( ..)
17161693 | hir:: ItemKind :: TyAlias ( ..) => { }
17171694 }
17181695 }
@@ -2079,30 +2056,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20792056 }
20802057 LazyArray :: default ( )
20812058 }
2082-
2083- fn encode_info_for_foreign_item ( & mut self , def_id : DefId , nitem : & hir:: ForeignItem < ' _ > ) {
2084- let tcx = self . tcx ;
2085-
2086- debug ! ( "EncodeContext::encode_info_for_foreign_item({:?})" , def_id) ;
2087-
2088- match nitem. kind {
2089- hir:: ForeignItemKind :: Fn ( _, ref names, _) => {
2090- self . tables . asyncness . set_some ( def_id. index , hir:: IsAsync :: NotAsync ) ;
2091- record_array ! ( self . tables. fn_arg_names[ def_id] <- * names) ;
2092- let constness = if self . tcx . is_const_fn_raw ( def_id) {
2093- hir:: Constness :: Const
2094- } else {
2095- hir:: Constness :: NotConst
2096- } ;
2097- self . tables . constness . set_some ( def_id. index , constness) ;
2098- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
2099- }
2100- hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => { }
2101- }
2102- if let hir:: ForeignItemKind :: Fn ( ..) = nitem. kind {
2103- self . tables . is_intrinsic . set ( def_id. index , tcx. is_intrinsic ( def_id) ) ;
2104- }
2105- }
21062059}
21072060
21082061// FIXME(eddyb) make metadata encoding walk over all definitions, instead of HIR.
@@ -2120,10 +2073,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EncodeContext<'a, 'tcx> {
21202073 intravisit:: walk_item ( self , item) ;
21212074 self . encode_info_for_item ( item) ;
21222075 }
2123- fn visit_foreign_item ( & mut self , ni : & ' tcx hir:: ForeignItem < ' tcx > ) {
2124- intravisit:: walk_foreign_item ( self , ni) ;
2125- self . encode_info_for_foreign_item ( ni. owner_id . to_def_id ( ) , ni) ;
2126- }
21272076 fn visit_generics ( & mut self , generics : & ' tcx hir:: Generics < ' tcx > ) {
21282077 intravisit:: walk_generics ( self , generics) ;
21292078 self . encode_info_for_generics ( generics) ;
0 commit comments