diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-07-19 13:30:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-19 13:30:52 +0200 |
| commit | e6904fc5b24a10e97d0a32908f49886e52e73990 (patch) | |
| tree | 1447d09895921da9f27af3f9bbcfee41a11e4b2a | |
| parent | ae90a8f2e148f1fd1e0e907912d274224215cb12 (diff) | |
| parent | e2ecb68a0eeee6db4d8f605374e656822186f8b4 (diff) | |
| download | rust-e6904fc5b24a10e97d0a32908f49886e52e73990.tar.gz rust-e6904fc5b24a10e97d0a32908f49886e52e73990.zip | |
Rollup merge of #99457 - SparrowLii:para_iter, r=fee1-dead
use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items`
Using `par_iter` in non-parallel mode will cause the entire process to abort when any iteration panics. So we can use `par_for_each_in` instead to make the error message consistent with parallel mode. This means that the compiler will output more error messages in some cases. This fixes the following ui tests when set `parallel-compiler = true`:
```
[ui] src/test\ui\privacy\privacy2.rs
[ui] src/test\ui\privacy\privacy3.rs
[ui] src/test\ui\type_length_limit.rs
```
This refers to #68171
Updates #75760
| -rw-r--r-- | compiler/rustc_data_structures/src/sync.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_monomorphize/src/collector.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/privacy/privacy2.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/privacy/privacy3.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/type_length_limit.stderr | 11 |
6 files changed, 28 insertions, 9 deletions
diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index cf0940df9e4..52952a7932d 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -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; diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 3a59b2069b3..0001e1aa53e 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -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 { diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index d9fa4d65b3a..e3cfb034e40 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -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, diff --git a/src/test/ui/privacy/privacy2.stderr b/src/test/ui/privacy/privacy2.stderr index c2a33ce1f59..882f314655d 100644 --- a/src/test/ui/privacy/privacy2.stderr +++ b/src/test/ui/privacy/privacy2.stderr @@ -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`. diff --git a/src/test/ui/privacy/privacy3.stderr b/src/test/ui/privacy/privacy3.stderr index 22c1e48b07d..42ce456d962 100644 --- a/src/test/ui/privacy/privacy3.stderr +++ b/src/test/ui/privacy/privacy3.stderr @@ -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`. diff --git a/src/test/ui/type_length_limit.stderr b/src/test/ui/type_length_limit.stderr index a2ddffff997..1508b84c1b6 100644 --- a/src/test/ui/type_length_limit.stderr +++ b/src/test/ui/type_length_limit.stderr @@ -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 |
