diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-18 19:20:59 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-22 08:04:24 +0200 |
| commit | f446bbce728d3fb7ec006b72b4eb7cf72160846a (patch) | |
| tree | 2768bbe980fa8d14de4afa9922000ac96d294203 | |
| parent | 86290effd511d9cd8b6339704a85495552c66c90 (diff) | |
| download | rust-f446bbce728d3fb7ec006b72b4eb7cf72160846a.tar.gz rust-f446bbce728d3fb7ec006b72b4eb7cf72160846a.zip | |
Fix parallel compiler.
| -rw-r--r-- | compiler/rustc_middle/src/hir/mod.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/wfcheck.rs | 9 |
2 files changed, 21 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 09b142e0c41..8622a620721 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -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> { diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 8676db61bf8..174f74f062b 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -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)); } /////////////////////////////////////////////////////////////////////////// |
