@@ -39,6 +39,7 @@ pub fn fn_sig<'hir>(node: Node<'hir>) -> Option<&'hir FnSig<'hir>> {
39
39
}
40
40
}
41
41
42
+ #[ inline]
42
43
pub fn associated_body < ' hir > ( node : Node < ' hir > ) -> Option < BodyId > {
43
44
match node {
44
45
Node :: Item ( Item {
@@ -1292,27 +1293,19 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalDefId) -> Module
1292
1293
}
1293
1294
1294
1295
fn visit_foreign_item ( & mut self , item : & ' hir ForeignItem < ' hir > ) {
1295
- if associated_body ( Node :: ForeignItem ( item) ) . is_some ( ) {
1296
- self . body_owners . push ( item. def_id ) ;
1297
- }
1298
-
1299
1296
self . foreign_items . push ( item. foreign_item_id ( ) ) ;
1300
1297
intravisit:: walk_foreign_item ( self , item)
1301
1298
}
1302
1299
1303
1300
fn visit_expr ( & mut self , ex : & ' hir Expr < ' hir > ) {
1304
- if matches ! ( ex. kind, ExprKind :: Closure { .. } )
1305
- && associated_body ( Node :: Expr ( ex) ) . is_some ( )
1306
- {
1301
+ if matches ! ( ex. kind, ExprKind :: Closure { .. } ) {
1307
1302
self . body_owners . push ( self . tcx . hir ( ) . local_def_id ( ex. hir_id ) ) ;
1308
1303
}
1309
1304
intravisit:: walk_expr ( self , ex)
1310
1305
}
1311
1306
1312
1307
fn visit_anon_const ( & mut self , c : & ' hir AnonConst ) {
1313
- if associated_body ( Node :: AnonConst ( c) ) . is_some ( ) {
1314
- self . body_owners . push ( self . tcx . hir ( ) . local_def_id ( c. hir_id ) ) ;
1315
- }
1308
+ self . body_owners . push ( self . tcx . hir ( ) . local_def_id ( c. hir_id ) ) ;
1316
1309
intravisit:: walk_anon_const ( self , c)
1317
1310
}
1318
1311
}
@@ -1382,10 +1375,6 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
1382
1375
}
1383
1376
1384
1377
fn visit_foreign_item ( & mut self , item : & ' hir ForeignItem < ' hir > ) {
1385
- if associated_body ( Node :: ForeignItem ( item) ) . is_some ( ) {
1386
- self . body_owners . push ( item. def_id ) ;
1387
- }
1388
-
1389
1378
self . foreign_items . push ( item. foreign_item_id ( ) ) ;
1390
1379
intravisit:: walk_foreign_item ( self , item)
1391
1380
}
@@ -1409,18 +1398,14 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
1409
1398
}
1410
1399
1411
1400
fn visit_expr ( & mut self , ex : & ' hir Expr < ' hir > ) {
1412
- if matches ! ( ex. kind, ExprKind :: Closure { .. } )
1413
- && associated_body ( Node :: Expr ( ex) ) . is_some ( )
1414
- {
1401
+ if matches ! ( ex. kind, ExprKind :: Closure { .. } ) {
1415
1402
self . body_owners . push ( self . tcx . hir ( ) . local_def_id ( ex. hir_id ) ) ;
1416
1403
}
1417
1404
intravisit:: walk_expr ( self , ex)
1418
1405
}
1419
1406
1420
1407
fn visit_anon_const ( & mut self , c : & ' hir AnonConst ) {
1421
- if associated_body ( Node :: AnonConst ( c) ) . is_some ( ) {
1422
- self . body_owners . push ( self . tcx . hir ( ) . local_def_id ( c. hir_id ) ) ;
1423
- }
1408
+ self . body_owners . push ( self . tcx . hir ( ) . local_def_id ( c. hir_id ) ) ;
1424
1409
intravisit:: walk_anon_const ( self , c)
1425
1410
}
1426
1411
}
0 commit comments