Skip to content

Commit 20d0225

Browse files
committed
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
1 parent 2f3f27b commit 20d0225

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

library/std/src/sync/barrier.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::panic::RefUnwindSafe;
2+
13
use crate::fmt;
24
use crate::sync::nonpoison::{Condvar, Mutex};
35

@@ -31,6 +33,9 @@ pub struct Barrier {
3133
num_threads: usize,
3234
}
3335

36+
#[stable(feature = "rust1", since = "1.0.0")]
37+
impl RefUnwindSafe for Barrier {}
38+
3439
// The inner state of a double barrier
3540
struct BarrierState {
3641
count: usize,

library/std/tests/sync/barrier.rs

Lines changed: 10 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,12 @@ fn test_barrier() {
3334
}
3435
assert!(leader_found);
3536
}
37+
38+
#[expect(dead_code, reason = "this is essentially a compile pass test")]
39+
fn check_barrier_is_ref_unwind_safe() {
40+
let barrier = Arc::new(Barrier::new(10));
41+
42+
fn check<T: RefUnwindSafe>(_: T) {}
43+
44+
check(barrier);
45+
}

0 commit comments

Comments
 (0)