@@ -146,25 +146,30 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
146
146
}
147
147
148
148
impl < ' hir > Map < ' hir > {
149
+ #[ inline]
149
150
pub fn krate ( self ) -> & ' hir Crate < ' hir > {
150
151
self . tcx . hir_crate ( ( ) )
151
152
}
152
153
154
+ #[ inline]
153
155
pub fn root_module ( self ) -> & ' hir Mod < ' hir > {
154
156
match self . tcx . hir_owner ( CRATE_DEF_ID ) . map ( |o| o. node ) {
155
157
Some ( OwnerNode :: Crate ( item) ) => item,
156
158
_ => bug ! ( ) ,
157
159
}
158
160
}
159
161
162
+ #[ inline]
160
163
pub fn items ( self ) -> impl Iterator < Item = ItemId > + ' hir {
161
164
self . tcx . hir_crate_items ( ( ) ) . items . iter ( ) . copied ( )
162
165
}
163
166
167
+ #[ inline]
164
168
pub fn module_items ( self , module : LocalDefId ) -> impl Iterator < Item = ItemId > + ' hir {
165
169
self . tcx . hir_module_items ( module) . items ( )
166
170
}
167
171
172
+ #[ inline]
168
173
pub fn par_for_each_item ( self , f : impl Fn ( ItemId ) + Sync + Send ) {
169
174
par_for_each_in ( & self . tcx . hir_crate_items ( ( ) ) . items [ ..] , |id| f ( * id) ) ;
170
175
}
@@ -487,10 +492,12 @@ impl<'hir> Map<'hir> {
487
492
/// Returns an iterator of the `DefId`s for all body-owners in this
488
493
/// crate. If you would prefer to iterate over the bodies
489
494
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
495
+ #[ inline]
490
496
pub fn body_owners ( self ) -> impl Iterator < Item = LocalDefId > + ' hir {
491
497
self . tcx . hir_crate_items ( ( ) ) . body_owners . iter ( ) . copied ( )
492
498
}
493
499
500
+ #[ inline]
494
501
pub fn par_body_owners ( self , f : impl Fn ( LocalDefId ) + Sync + Send ) {
495
502
par_for_each_in ( & self . tcx . hir_crate_items ( ( ) ) . body_owners [ ..] , |& def_id| f ( def_id) ) ;
496
503
}
@@ -632,12 +639,14 @@ impl<'hir> Map<'hir> {
632
639
633
640
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
634
641
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
642
+ #[ inline]
635
643
pub fn parent_iter ( self , current_id : HirId ) -> ParentHirIterator < ' hir > {
636
644
ParentHirIterator { current_id, map : self }
637
645
}
638
646
639
647
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
640
648
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
649
+ #[ inline]
641
650
pub fn parent_owner_iter ( self , current_id : HirId ) -> ParentOwnerIterator < ' hir > {
642
651
ParentOwnerIterator { current_id, map : self }
643
652
}
0 commit comments