@@ -1315,6 +1315,19 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1315
1315
if should_encode_type ( tcx, local_id, def_kind) {
1316
1316
record ! ( self . tables. type_of[ def_id] <- self . tcx. type_of( def_id) ) ;
1317
1317
}
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
+ }
1318
1331
if let DefKind :: TyParam = def_kind {
1319
1332
let default = self . tcx . object_lifetime_default ( def_id) ;
1320
1333
record ! ( self . tables. object_lifetime_default[ def_id] <- default ) ;
@@ -1446,19 +1459,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1446
1459
self . tables . assoc_container . set_some ( def_id. index , trait_item. container ) ;
1447
1460
1448
1461
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 => { }
1455
1463
ty:: AssocKind :: Type => {
1456
1464
self . encode_explicit_item_bounds ( def_id) ;
1457
1465
}
1458
1466
}
1459
- if trait_item. kind == ty:: AssocKind :: Fn {
1460
- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1461
- }
1462
1467
if let Some ( rpitit_info) = trait_item. opt_rpitit_info {
1463
1468
let rpitit_info = self . lazy ( rpitit_info) ;
1464
1469
self . tables . opt_rpitit_info . set_some ( def_id. index , rpitit_info) ;
@@ -1467,36 +1472,15 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1467
1472
1468
1473
fn encode_info_for_impl_item ( & mut self , def_id : DefId ) {
1469
1474
debug ! ( "EncodeContext::encode_info_for_impl_item({:?})" , def_id) ;
1470
- let tcx = self . tcx ;
1471
1475
1472
1476
let defaultness = self . tcx . defaultness ( def_id. expect_local ( ) ) ;
1473
1477
self . tables . defaultness . set_some ( def_id. index , defaultness) ;
1474
1478
let impl_item = self . tcx . associated_item ( def_id) ;
1475
1479
self . tables . assoc_container . set_some ( def_id. index , impl_item. container ) ;
1476
1480
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
- }
1493
1481
if let Some ( trait_item_def_id) = impl_item. trait_item_def_id {
1494
1482
self . tables . trait_item_def_id . set_some ( def_id. index , trait_item_def_id. into ( ) ) ;
1495
1483
}
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
- }
1500
1484
if let Some ( rpitit_info) = impl_item. opt_rpitit_info {
1501
1485
let rpitit_info = self . lazy ( rpitit_info) ;
1502
1486
self . tables . opt_rpitit_info . set_some ( def_id. index , rpitit_info) ;
@@ -1624,7 +1608,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1624
1608
}
1625
1609
1626
1610
fn encode_info_for_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1627
- let tcx = self . tcx ;
1628
1611
let def_id = item. owner_id . to_def_id ( ) ;
1629
1612
debug ! ( "EncodeContext::encode_info_for_item({:?})" , def_id) ;
1630
1613
@@ -1636,13 +1619,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1636
1619
} ;
1637
1620
1638
1621
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
- }
1646
1622
hir:: ItemKind :: Macro ( ref macro_def, _) => {
1647
1623
self . tables . is_macro_rules . set ( def_id. index , macro_def. macro_rules ) ;
1648
1624
record ! ( self . tables. macro_definition[ def_id] <- & * macro_def. body) ;
@@ -1691,7 +1667,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1691
1667
hir:: ItemKind :: Trait ( ..) => {
1692
1668
record ! ( self . tables. trait_def[ def_id] <- self . tcx. trait_def( def_id) ) ;
1693
1669
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 ) ;
1695
1671
record_array ! ( self . tables. module_children_non_reexports[ def_id] <-
1696
1672
module_children. iter( ) . map( |child| child. res. def_id( ) . index) ) ;
1697
1673
@@ -1713,6 +1689,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1713
1689
| hir:: ItemKind :: Union ( ..)
1714
1690
| hir:: ItemKind :: ForeignMod { .. }
1715
1691
| hir:: ItemKind :: GlobalAsm ( ..)
1692
+ | hir:: ItemKind :: Fn ( ..)
1716
1693
| hir:: ItemKind :: TyAlias ( ..) => { }
1717
1694
}
1718
1695
}
@@ -2079,30 +2056,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
2079
2056
}
2080
2057
LazyArray :: default ( )
2081
2058
}
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
- }
2106
2059
}
2107
2060
2108
2061
// 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> {
2120
2073
intravisit:: walk_item ( self , item) ;
2121
2074
self . encode_info_for_item ( item) ;
2122
2075
}
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
- }
2127
2076
fn visit_generics ( & mut self , generics : & ' tcx hir:: Generics < ' tcx > ) {
2128
2077
intravisit:: walk_generics ( self , generics) ;
2129
2078
self . encode_info_for_generics ( generics) ;
0 commit comments