Skip to content

Commit

Permalink
Fix parallel compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jun 22, 2022
1 parent 86290ef commit f446bbc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
17 changes: 17 additions & 0 deletions compiler/rustc_middle/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::ty::query::Providers;
use crate::ty::{DefIdTree, ImplSubject, TyCtxt};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::*;
use rustc_query_system::ich::StableHashingContext;
Expand Down Expand Up @@ -61,6 +62,22 @@ impl ModuleItems {
pub fn foreign_items(&self) -> impl Iterator<Item = ForeignItemId> + '_ {
self.foreign_items.iter().copied()
}

pub fn par_items(&self, f: impl Fn(ItemId) + Send + Sync) {
par_for_each_in(&self.items[..], |&id| f(id))
}

pub fn par_trait_items(&self, f: impl Fn(TraitItemId) + Send + Sync) {
par_for_each_in(&self.trait_items[..], |&id| f(id))
}

pub fn par_impl_items(&self, f: impl Fn(ImplItemId) + Send + Sync) {
par_for_each_in(&self.impl_items[..], |&id| f(id))
}

pub fn par_foreign_items(&self, f: impl Fn(ForeignItemId) + Send + Sync) {
par_for_each_in(&self.foreign_items[..], |&id| f(id))
}
}

impl<'tcx> TyCtxt<'tcx> {
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par

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

fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalDefId) {
let items = tcx.hir_module_items(module);
par_for_each_in(items.items(), |item| tcx.ensure().check_well_formed(item.def_id));
par_for_each_in(items.impl_items(), |item| tcx.ensure().check_well_formed(item.def_id));
par_for_each_in(items.trait_items(), |item| tcx.ensure().check_well_formed(item.def_id));
par_for_each_in(items.foreign_items(), |item| tcx.ensure().check_well_formed(item.def_id));
items.par_items(|item| tcx.ensure().check_well_formed(item.def_id));
items.par_impl_items(|item| tcx.ensure().check_well_formed(item.def_id));
items.par_trait_items(|item| tcx.ensure().check_well_formed(item.def_id));
items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.def_id));
}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit f446bbc

Please sign in to comment.