Skip to content

Commit b599cf4

Browse files
committed
inline associated_body
Signed-off-by: Miguel Guarniz <[email protected]>
1 parent c6e7c05 commit b599cf4

File tree

1 file changed

+5
-20
lines changed
  • compiler/rustc_middle/src/hir/map

1 file changed

+5
-20
lines changed

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub fn fn_sig<'hir>(node: Node<'hir>) -> Option<&'hir FnSig<'hir>> {
3939
}
4040
}
4141

42+
#[inline]
4243
pub fn associated_body<'hir>(node: Node<'hir>) -> Option<BodyId> {
4344
match node {
4445
Node::Item(Item {
@@ -1292,27 +1293,19 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalDefId) -> Module
12921293
}
12931294

12941295
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-
12991296
self.foreign_items.push(item.foreign_item_id());
13001297
intravisit::walk_foreign_item(self, item)
13011298
}
13021299

13031300
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 { .. }) {
13071302
self.body_owners.push(self.tcx.hir().local_def_id(ex.hir_id));
13081303
}
13091304
intravisit::walk_expr(self, ex)
13101305
}
13111306

13121307
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));
13161309
intravisit::walk_anon_const(self, c)
13171310
}
13181311
}
@@ -1382,10 +1375,6 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13821375
}
13831376

13841377
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-
13891378
self.foreign_items.push(item.foreign_item_id());
13901379
intravisit::walk_foreign_item(self, item)
13911380
}
@@ -1409,18 +1398,14 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
14091398
}
14101399

14111400
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 { .. }) {
14151402
self.body_owners.push(self.tcx.hir().local_def_id(ex.hir_id));
14161403
}
14171404
intravisit::walk_expr(self, ex)
14181405
}
14191406

14201407
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));
14241409
intravisit::walk_anon_const(self, c)
14251410
}
14261411
}

0 commit comments

Comments
 (0)