Skip to content

Commit f446bbc

Browse files
committed
Fix parallel compiler.
1 parent 86290ef commit f446bbc

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

compiler/rustc_middle/src/hir/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::ty::query::Providers;
1010
use crate::ty::{DefIdTree, ImplSubject, TyCtxt};
1111
use rustc_data_structures::fingerprint::Fingerprint;
1212
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
13+
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
1314
use rustc_hir::def_id::{DefId, LocalDefId};
1415
use rustc_hir::*;
1516
use rustc_query_system::ich::StableHashingContext;
@@ -61,6 +62,22 @@ impl ModuleItems {
6162
pub fn foreign_items(&self) -> impl Iterator<Item = ForeignItemId> + '_ {
6263
self.foreign_items.iter().copied()
6364
}
65+
66+
pub fn par_items(&self, f: impl Fn(ItemId) + Send + Sync) {
67+
par_for_each_in(&self.items[..], |&id| f(id))
68+
}
69+
70+
pub fn par_trait_items(&self, f: impl Fn(TraitItemId) + Send + Sync) {
71+
par_for_each_in(&self.trait_items[..], |&id| f(id))
72+
}
73+
74+
pub fn par_impl_items(&self, f: impl Fn(ImplItemId) + Send + Sync) {
75+
par_for_each_in(&self.impl_items[..], |&id| f(id))
76+
}
77+
78+
pub fn par_foreign_items(&self, f: impl Fn(ForeignItemId) + Send + Sync) {
79+
par_for_each_in(&self.foreign_items[..], |&id| f(id))
80+
}
6481
}
6582

6683
impl<'tcx> TyCtxt<'tcx> {

compiler/rustc_typeck/src/check/wfcheck.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par
44

55
use rustc_ast as ast;
66
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
7-
use rustc_data_structures::sync::par_for_each_in;
87
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
98
use rustc_hir as hir;
109
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -1861,10 +1860,10 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, mut span: Span, id: hir::HirI
18611860

18621861
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalDefId) {
18631862
let items = tcx.hir_module_items(module);
1864-
par_for_each_in(items.items(), |item| tcx.ensure().check_well_formed(item.def_id));
1865-
par_for_each_in(items.impl_items(), |item| tcx.ensure().check_well_formed(item.def_id));
1866-
par_for_each_in(items.trait_items(), |item| tcx.ensure().check_well_formed(item.def_id));
1867-
par_for_each_in(items.foreign_items(), |item| tcx.ensure().check_well_formed(item.def_id));
1863+
items.par_items(|item| tcx.ensure().check_well_formed(item.def_id));
1864+
items.par_impl_items(|item| tcx.ensure().check_well_formed(item.def_id));
1865+
items.par_trait_items(|item| tcx.ensure().check_well_formed(item.def_id));
1866+
items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.def_id));
18681867
}
18691868

18701869
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)