Skip to content

Commit 91575f8

Browse files
committed
Use non-recursive algorithm in non-parallel compiler.
1 parent 6bbb079 commit 91575f8

File tree

1 file changed

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

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_ast as ast;
66
use rustc_data_structures::fingerprint::Fingerprint;
77
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
88
use rustc_data_structures::svh::Svh;
9-
use rustc_data_structures::sync::{self, par_iter};
109
use rustc_hir::def::{DefKind, Res};
1110
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE};
1211
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
@@ -571,13 +570,20 @@ impl<'hir> Map<'hir> {
571570
}
572571
}
573572

574-
pub fn par_for_each_module(&self, f: impl Fn(LocalDefId) + sync::Sync) {
575-
use rustc_data_structures::sync::ParallelIterator;
573+
#[cfg(not(parallel_compiler))]
574+
#[inline]
575+
pub fn par_for_each_module(&self, f: impl Fn(LocalDefId)) {
576+
self.for_each_module(f)
577+
}
578+
579+
#[cfg(parallel_compiler)]
580+
pub fn par_for_each_module(&self, f: impl Fn(LocalDefId) + Sync) {
581+
use rustc_data_structures::sync::{par_iter, ParallelIterator};
576582
par_iter_submodules(self.tcx, CRATE_DEF_ID, &f);
577583

578584
fn par_iter_submodules<F>(tcx: TyCtxt<'_>, module: LocalDefId, f: &F)
579585
where
580-
F: Fn(LocalDefId) + sync::Sync,
586+
F: Fn(LocalDefId) + Sync,
581587
{
582588
(*f)(module);
583589
let items = tcx.hir_module_items(module);

0 commit comments

Comments
 (0)