Fix parallel compiler.

This commit is contained in:
Camille GILLOT 2022-06-18 19:20:59 +02:00
parent 86290effd5
commit f446bbce72
2 changed files with 21 additions and 5 deletions

View File

@ -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;
@ -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> {

View File

@ -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};
@ -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));
}
///////////////////////////////////////////////////////////////////////////