Skip to content

Commit 4c5ec30

Browse files
committed
Inline a few short methods.
1 parent 9058342 commit 4c5ec30

File tree

1 file changed

+9
-0
lines changed
  • compiler/rustc_middle/src/hir/map

1 file changed

+9
-0
lines changed

compiler/rustc_middle/src/hir/map/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,30 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
146146
}
147147

148148
impl<'hir> Map<'hir> {
149+
#[inline]
149150
pub fn krate(self) -> &'hir Crate<'hir> {
150151
self.tcx.hir_crate(())
151152
}
152153

154+
#[inline]
153155
pub fn root_module(self) -> &'hir Mod<'hir> {
154156
match self.tcx.hir_owner(CRATE_DEF_ID).map(|o| o.node) {
155157
Some(OwnerNode::Crate(item)) => item,
156158
_ => bug!(),
157159
}
158160
}
159161

162+
#[inline]
160163
pub fn items(self) -> impl Iterator<Item = ItemId> + 'hir {
161164
self.tcx.hir_crate_items(()).items.iter().copied()
162165
}
163166

167+
#[inline]
164168
pub fn module_items(self, module: LocalDefId) -> impl Iterator<Item = ItemId> + 'hir {
165169
self.tcx.hir_module_items(module).items()
166170
}
167171

172+
#[inline]
168173
pub fn par_for_each_item(self, f: impl Fn(ItemId) + Sync + Send) {
169174
par_for_each_in(&self.tcx.hir_crate_items(()).items[..], |id| f(*id));
170175
}
@@ -487,10 +492,12 @@ impl<'hir> Map<'hir> {
487492
/// Returns an iterator of the `DefId`s for all body-owners in this
488493
/// crate. If you would prefer to iterate over the bodies
489494
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
495+
#[inline]
490496
pub fn body_owners(self) -> impl Iterator<Item = LocalDefId> + 'hir {
491497
self.tcx.hir_crate_items(()).body_owners.iter().copied()
492498
}
493499

500+
#[inline]
494501
pub fn par_body_owners(self, f: impl Fn(LocalDefId) + Sync + Send) {
495502
par_for_each_in(&self.tcx.hir_crate_items(()).body_owners[..], |&def_id| f(def_id));
496503
}
@@ -632,12 +639,14 @@ impl<'hir> Map<'hir> {
632639

633640
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
634641
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
642+
#[inline]
635643
pub fn parent_iter(self, current_id: HirId) -> ParentHirIterator<'hir> {
636644
ParentHirIterator { current_id, map: self }
637645
}
638646

639647
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
640648
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
649+
#[inline]
641650
pub fn parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'hir> {
642651
ParentOwnerIterator { current_id, map: self }
643652
}

0 commit comments

Comments
 (0)