1
Fork 0

use par_for_each_in in par_body_owners and collect_crate_mono_items

This commit is contained in:
SparrowLii 2022-07-19 17:00:51 +08:00
parent 96c2df810b
commit e2ecb68a0e
6 changed files with 28 additions and 9 deletions

View file

@ -146,7 +146,7 @@ cfg_if! {
t.into_iter()
}
pub fn par_for_each_in<T: IntoIterator>(t: T, for_each: impl Fn(T::Item) + Sync + Send) {
pub fn par_for_each_in<T: IntoIterator>(t: T, mut for_each: impl FnMut(T::Item) + Sync + Send) {
// We catch panics here ensuring that all the loop iterations execute.
// This makes behavior consistent with the parallel compiler.
let mut panic = None;

View file

@ -491,9 +491,7 @@ impl<'hir> Map<'hir> {
}
pub fn par_body_owners<F: Fn(LocalDefId) + Sync + Send>(self, f: F) {
use rustc_data_structures::sync::{par_iter, ParallelIterator};
par_iter(&self.tcx.hir_crate_items(()).body_owners[..]).for_each(|&def_id| f(def_id));
par_for_each_in(&self.tcx.hir_crate_items(()).body_owners[..], |&def_id| f(def_id));
}
pub fn ty_param_owner(self, def_id: LocalDefId) -> LocalDefId {

View file

@ -180,7 +180,7 @@
//! regardless of whether it is actually needed or not.
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator};
use rustc_data_structures::sync::{par_for_each_in, MTLock, MTRef};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
@ -346,7 +346,7 @@ pub fn collect_crate_mono_items(
let inlining_map: MTRef<'_, _> = &mut inlining_map;
tcx.sess.time("monomorphization_collector_graph_walk", || {
par_iter(roots).for_each(|root| {
par_for_each_in(roots, |root| {
let mut recursion_depths = DefIdMap::default();
collect_items_rec(
tcx,

View file

@ -23,7 +23,13 @@ LL | pub fn foo() {}
error: requires `sized` lang_item
error: aborting due to 3 previous errors
error: requires `sized` lang_item
error: requires `sized` lang_item
error: requires `sized` lang_item
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0432, E0603.
For more information about an error, try `rustc --explain E0432`.

View file

@ -6,6 +6,12 @@ LL | use bar::gpriv;
error: requires `sized` lang_item
error: aborting due to 2 previous errors
error: requires `sized` lang_item
error: requires `sized` lang_item
error: requires `sized` lang_item
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0432`.

View file

@ -7,5 +7,14 @@ LL | pub fn drop<T>(_x: T) {}
= note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt'
= help: consider adding a `#![type_length_limit="8"]` attribute to your crate
error: aborting due to previous error
error: reached the type-length limit while instantiating `<[closure@std::rt::lang_start<()...e<()>>::call_once - shim(vtable)`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt'
= help: consider adding a `#![type_length_limit="8"]` attribute to your crate
error: aborting due to 2 previous errors