diff options
| author | SparrowLii <liyuan179@huawei.com> | 2022-06-27 16:39:10 +0800 |
|---|---|---|
| committer | SparrowLii <liyuan179@huawei.com> | 2022-06-27 16:39:10 +0800 |
| commit | ec137f29c5812df6461095dbc5c62ce3fe4ebc01 (patch) | |
| tree | a50caa0d176e5a49ab110c478b9f368c575814f1 /compiler/rustc_data_structures/src | |
| parent | 3b0d4813ab461ec81eab8980bb884691c97c5a35 (diff) | |
| download | rust-ec137f29c5812df6461095dbc5c62ce3fe4ebc01.tar.gz rust-ec137f29c5812df6461095dbc5c62ce3fe4ebc01.zip | |
catch unwind of every iter in parallel mode during wfcheck
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/sync.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index feb82cb0938..4437c0b1b69 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -21,6 +21,7 @@ use crate::owning_ref::{Erased, OwningRef}; use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; use std::ops::{Deref, DerefMut}; +use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; pub use std::sync::atomic::Ordering; pub use std::sync::atomic::Ordering::SeqCst; @@ -41,7 +42,6 @@ cfg_if! { } use std::ops::Add; - use std::panic::{resume_unwind, catch_unwind, AssertUnwindSafe}; /// This is a single threaded variant of `AtomicU64`, `AtomicUsize`, etc. /// It has explicit ordering arguments and is only intended for use with @@ -339,7 +339,10 @@ cfg_if! { t: T, for_each: impl Fn(T::Item) + Sync + Send, ) { - t.into_par_iter().for_each(for_each) + let ps: Vec<_> = t.into_par_iter().map(|i| catch_unwind(AssertUnwindSafe(|| for_each(i)))).collect(); + ps.into_iter().for_each(|p| if let Err(panic) = p { + resume_unwind(panic) + }); } pub type MetadataRef = OwningRef<Box<dyn Erased + Send + Sync>, [u8]>; |
