Skip to content

Commit c9658f9

Browse files
authored
Unrolled build for #146322
Rollup merge of #146322 - weiznich:fix/146087, r=joboet Make Barrier RefUnwindSafe again This commit manually implements `RefUnwindSafe` for `std::sync::Barrier` to fix #146087. This is a fix for a regression indroduced by e95db59
2 parents 565a9ca + ef7b036 commit c9658f9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

library/std/src/sync/barrier.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::fmt;
2+
use crate::panic::RefUnwindSafe;
23
use crate::sync::nonpoison::{Condvar, Mutex};
34

45
/// A barrier enables multiple threads to synchronize the beginning
@@ -31,6 +32,9 @@ pub struct Barrier {
3132
num_threads: usize,
3233
}
3334

35+
#[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")]
36+
impl RefUnwindSafe for Barrier {}
37+
3438
// The inner state of a double barrier
3539
struct BarrierState {
3640
count: usize,

library/std/tests/sync/barrier.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::panic::RefUnwindSafe;
12
use std::sync::mpsc::{TryRecvError, channel};
23
use std::sync::{Arc, Barrier};
34
use std::thread;
@@ -33,3 +34,11 @@ fn test_barrier() {
3334
}
3435
assert!(leader_found);
3536
}
37+
38+
/// Asserts that `Barrier` is ref unwind safe.
39+
///
40+
/// See <https://github.com/rust-lang/rust/issues/146087>.
41+
const _: () = {
42+
const fn check_ref_unwind_safe<T: RefUnwindSafe>() {}
43+
check_ref_unwind_safe::<Barrier>();
44+
};

0 commit comments

Comments
 (0)