@@ -1181,6 +1181,21 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1181
1181
if should_encode_type ( tcx, local_id, def_kind) {
1182
1182
record ! ( self . tables. type_of[ def_id] <- self . tcx. type_of( def_id) ) ;
1183
1183
}
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
+ }
1184
1199
if let DefKind :: TyParam = def_kind {
1185
1200
let default = self . tcx . object_lifetime_default ( def_id) ;
1186
1201
record ! ( self . tables. object_lifetime_default[ def_id] <- default ) ;
@@ -1342,54 +1357,24 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1342
1357
self . tables . assoc_container . set ( def_id. index , trait_item. container ) ;
1343
1358
1344
1359
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 => { }
1351
1361
ty:: AssocKind :: Type => {
1352
1362
self . encode_explicit_item_bounds ( def_id) ;
1353
1363
}
1354
1364
}
1355
- if trait_item. kind == ty:: AssocKind :: Fn {
1356
- record ! ( self . tables. fn_sig[ def_id] <- tcx. fn_sig( def_id) ) ;
1357
- }
1358
1365
}
1359
1366
1360
1367
fn encode_info_for_impl_item ( & mut self , def_id : DefId ) {
1361
1368
debug ! ( "EncodeContext::encode_info_for_impl_item({:?})" , def_id) ;
1362
- let tcx = self . tcx ;
1363
1369
1364
1370
let ast_item = self . tcx . hir ( ) . expect_impl_item ( def_id. expect_local ( ) ) ;
1365
1371
self . tables . impl_defaultness . set ( def_id. index , ast_item. defaultness ) ;
1366
1372
let impl_item = self . tcx . associated_item ( def_id) ;
1367
1373
self . tables . assoc_container . set ( def_id. index , impl_item. container ) ;
1368
1374
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
- }
1384
1375
if let Some ( trait_item_def_id) = impl_item. trait_item_def_id {
1385
1376
self . tables . trait_item_def_id . set ( def_id. index , trait_item_def_id. into ( ) ) ;
1386
1377
}
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
- }
1393
1378
}
1394
1379
1395
1380
fn encode_mir ( & mut self ) {
@@ -1512,11 +1497,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1512
1497
debug ! ( "EncodeContext::encode_info_for_item({:?})" , def_id) ;
1513
1498
1514
1499
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
- }
1520
1500
hir:: ItemKind :: Macro ( ref macro_def, _) => {
1521
1501
if macro_def. macro_rules {
1522
1502
self . tables . is_macro_rules . set_nullable ( def_id. index , true ) ;
@@ -1599,6 +1579,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1599
1579
| hir:: ItemKind :: Const ( ..)
1600
1580
| hir:: ItemKind :: ForeignMod { .. }
1601
1581
| hir:: ItemKind :: GlobalAsm ( ..)
1582
+ | hir:: ItemKind :: Fn ( ..)
1602
1583
| hir:: ItemKind :: TyAlias ( ..) => { }
1603
1584
} ;
1604
1585
// FIXME(eddyb) there should be a nicer way to do this.
@@ -1633,12 +1614,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1633
1614
}
1634
1615
_ => { }
1635
1616
}
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
- }
1642
1617
if let hir:: ItemKind :: Impl { .. } = item. kind {
1643
1618
if let Some ( trait_ref) = self . tcx . impl_trait_ref ( def_id) {
1644
1619
record ! ( self . tables. impl_trait_ref[ def_id] <- trait_ref) ;
@@ -2016,32 +1991,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
2016
1991
}
2017
1992
LazyArray :: empty ( )
2018
1993
}
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
- }
2045
1994
}
2046
1995
2047
1996
// 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> {
2062
2011
_ => self . encode_info_for_item ( item. owner_id . to_def_id ( ) , item) ,
2063
2012
}
2064
2013
}
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
- }
2069
2014
fn visit_generics ( & mut self , generics : & ' tcx hir:: Generics < ' tcx > ) {
2070
2015
intravisit:: walk_generics ( self , generics) ;
2071
2016
self . encode_info_for_generics ( generics) ;
0 commit comments