diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-08 17:24:03 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-12 16:33:18 +0200 |
| commit | 91575f89ccf6111f27ae8a65612e5a14ebd54900 (patch) | |
| tree | b81b7169d353b1caeeb1e20e2419dc4770ca7310 | |
| parent | 6bbb0792ea7cf0322b896f1cf2a9d57b418ef106 (diff) | |
| download | rust-91575f89ccf6111f27ae8a65612e5a14ebd54900.tar.gz rust-91575f89ccf6111f27ae8a65612e5a14ebd54900.zip | |
Use non-recursive algorithm in non-parallel compiler.
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index ef46771cd0f..fa186f4a931 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -6,7 +6,6 @@ use rustc_ast as ast; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::svh::Svh; -use rustc_data_structures::sync::{self, par_iter}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; @@ -571,13 +570,20 @@ impl<'hir> Map<'hir> { } } - pub fn par_for_each_module(&self, f: impl Fn(LocalDefId) + sync::Sync) { - use rustc_data_structures::sync::ParallelIterator; + #[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::Sync, + F: Fn(LocalDefId) + Sync, { (*f)(module); let items = tcx.hir_module_items(module); |
