Skip to content

Commit 9058342

Browse files
committed
Simplify implementation for par_for_each_module.
1 parent 038f9e6 commit 9058342

File tree

1 file changed

+4
-19
lines changed
  • compiler/rustc_middle/src/hir/map

1 file changed

+4
-19
lines changed

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

+4-19
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<'hir> Map<'hir> {
491491
self.tcx.hir_crate_items(()).body_owners.iter().copied()
492492
}
493493

494-
pub fn par_body_owners<F: Fn(LocalDefId) + Sync + Send>(self, f: F) {
494+
pub fn par_body_owners(self, f: impl Fn(LocalDefId) + Sync + Send) {
495495
par_for_each_in(&self.tcx.hir_crate_items(()).body_owners[..], |&def_id| f(def_id));
496496
}
497497

@@ -624,25 +624,10 @@ impl<'hir> Map<'hir> {
624624
}
625625
}
626626

627-
#[cfg(not(parallel_compiler))]
628627
#[inline]
629-
pub fn par_for_each_module(self, f: impl Fn(LocalDefId)) {
630-
self.for_each_module(f)
631-
}
632-
633-
#[cfg(parallel_compiler)]
634-
pub fn par_for_each_module(self, f: impl Fn(LocalDefId) + Sync) {
635-
use rustc_data_structures::sync::{par_iter, ParallelIterator};
636-
par_iter_submodules(self.tcx, CRATE_DEF_ID, &f);
637-
638-
fn par_iter_submodules<F>(tcx: TyCtxt<'_>, module: LocalDefId, f: &F)
639-
where
640-
F: Fn(LocalDefId) + Sync,
641-
{
642-
(*f)(module);
643-
let items = tcx.hir_module_items(module);
644-
par_iter(&items.submodules[..]).for_each(|&sm| par_iter_submodules(tcx, sm, f));
645-
}
628+
pub fn par_for_each_module(self, f: impl Fn(LocalDefId) + Sync + Send) {
629+
let crate_items = self.tcx.hir_crate_items(());
630+
par_for_each_in(&crate_items.submodules[..], |module| f(*module))
646631
}
647632

648633
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`

0 commit comments

Comments
 (0)