diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-07-30 22:44:23 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-07-30 22:44:23 +0200 |
| commit | 905834232bf7da7ae2b282806b9de4f102040d1d (patch) | |
| tree | 7fe150e913e0157e7594bf1a3d060d9463550805 | |
| parent | 038f9e6bef9c8fcf122d93a8a33ac546f5606eb3 (diff) | |
| download | rust-905834232bf7da7ae2b282806b9de4f102040d1d.tar.gz rust-905834232bf7da7ae2b282806b9de4f102040d1d.zip | |
Simplify implementation for par_for_each_module.
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 47b04c33ec1..fa64b98d62f 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -491,7 +491,7 @@ impl<'hir> Map<'hir> { self.tcx.hir_crate_items(()).body_owners.iter().copied() } - pub fn par_body_owners<F: Fn(LocalDefId) + Sync + Send>(self, f: F) { + pub fn par_body_owners(self, f: impl Fn(LocalDefId) + Sync + Send) { par_for_each_in(&self.tcx.hir_crate_items(()).body_owners[..], |&def_id| f(def_id)); } @@ -624,25 +624,10 @@ impl<'hir> Map<'hir> { } } - #[cfg(not(parallel_compiler))] #[inline] - pub fn par_for_each_module(self, f: impl Fn(LocalDefId)) { - self.for_each_module(f) - } - - #[cfg(parallel_compiler)] - pub fn par_for_each_module(self, f: impl Fn(LocalDefId) + Sync) { - use rustc_data_structures::sync::{par_iter, ParallelIterator}; - par_iter_submodules(self.tcx, CRATE_DEF_ID, &f); - - fn par_iter_submodules<F>(tcx: TyCtxt<'_>, module: LocalDefId, f: &F) - where - F: Fn(LocalDefId) + Sync, - { - (*f)(module); - let items = tcx.hir_module_items(module); - par_iter(&items.submodules[..]).for_each(|&sm| par_iter_submodules(tcx, sm, f)); - } + pub fn par_for_each_module(self, f: impl Fn(LocalDefId) + Sync + Send) { + let crate_items = self.tcx.hir_crate_items(()); + par_for_each_in(&crate_items.submodules[..], |module| f(*module)) } /// Returns an iterator for the nodes in the ancestor tree of the `current_id` |
