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 e95db591a4
This commit is contained in:
Georg Semmler 2025-09-08 08:17:06 +02:00
parent 2f3f27bf79
commit 20d02258fc
No known key found for this signature in database
GPG key ID: A87BCEE5205CE489
2 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,5 @@
use core::panic::RefUnwindSafe;
use crate::fmt;
use crate::sync::nonpoison::{Condvar, Mutex};
@ -31,6 +33,9 @@ pub struct Barrier {
num_threads: usize,
}
#[stable(feature = "rust1", since = "1.0.0")]
impl RefUnwindSafe for Barrier {}
// The inner state of a double barrier
struct BarrierState {
count: usize,

View file

@ -1,3 +1,4 @@
use std::panic::RefUnwindSafe;
use std::sync::mpsc::{TryRecvError, channel};
use std::sync::{Arc, Barrier};
use std::thread;
@ -33,3 +34,12 @@ fn test_barrier() {
}
assert!(leader_found);
}
#[expect(dead_code, reason = "this is essentially a compile pass test")]
fn check_barrier_is_ref_unwind_safe() {
let barrier = Arc::new(Barrier::new(10));
fn check<T: RefUnwindSafe>(_: T) {}
check(barrier);
}