File tree 1 file changed +5
-2
lines changed
compiler/rustc_data_structures/src
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use crate::owning_ref::{Erased, OwningRef};
21
21
use std:: collections:: HashMap ;
22
22
use std:: hash:: { BuildHasher , Hash } ;
23
23
use std:: ops:: { Deref , DerefMut } ;
24
+ use std:: panic:: { catch_unwind, resume_unwind, AssertUnwindSafe } ;
24
25
25
26
pub use std:: sync:: atomic:: Ordering ;
26
27
pub use std:: sync:: atomic:: Ordering :: SeqCst ;
@@ -41,7 +42,6 @@ cfg_if! {
41
42
}
42
43
43
44
use std:: ops:: Add ;
44
- use std:: panic:: { resume_unwind, catch_unwind, AssertUnwindSafe } ;
45
45
46
46
/// This is a single threaded variant of `AtomicU64`, `AtomicUsize`, etc.
47
47
/// It has explicit ordering arguments and is only intended for use with
@@ -339,7 +339,10 @@ cfg_if! {
339
339
t: T ,
340
340
for_each: impl Fn ( T :: Item ) + Sync + Send ,
341
341
) {
342
- t. into_par_iter( ) . for_each( for_each)
342
+ let ps: Vec <_> = t. into_par_iter( ) . map( |i| catch_unwind( AssertUnwindSafe ( || for_each( i) ) ) ) . collect( ) ;
343
+ ps. into_iter( ) . for_each( |p| if let Err ( panic) = p {
344
+ resume_unwind( panic)
345
+ } ) ;
343
346
}
344
347
345
348
pub type MetadataRef = OwningRef <Box <dyn Erased + Send + Sync >, [ u8 ] >;
You can’t perform that action at this time.
0 commit comments