From 8ad6e5fb671a2343b81aee29cb344f4804bbb0f4 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:27:54 +0000 Subject: [PATCH 1/2] Add UnwindSafe to Once --- library/std/src/sync/once.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index 1710c005393..47921283b21 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -90,6 +90,7 @@ mod tests; use crate::cell::Cell; use crate::fmt; use crate::marker; +use crate::panic::UnwindSafe; use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use crate::thread::{self, Thread}; @@ -123,6 +124,9 @@ unsafe impl Sync for Once {} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for Once {} +#[stable(feature = "sync_once_ref_unwind_safe", since = "1.59.0")] +impl UnwindSafe for Once {} + /// State yielded to [`Once::call_once_force()`]’s closure parameter. The state /// can be used to query the poison status of the [`Once`]. #[stable(feature = "once_poison", since = "1.51.0")] From 91161ed110c87b6e2dba08269e45509e317fbc73 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 20 Dec 2021 11:49:47 -0800 Subject: [PATCH 2/2] impl RefUnwindSafe for Once --- library/std/src/sync/once.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index 47921283b21..f76d0759561 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -90,7 +90,7 @@ mod tests; use crate::cell::Cell; use crate::fmt; use crate::marker; -use crate::panic::UnwindSafe; +use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use crate::thread::{self, Thread}; @@ -124,9 +124,12 @@ unsafe impl Sync for Once {} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for Once {} -#[stable(feature = "sync_once_ref_unwind_safe", since = "1.59.0")] +#[stable(feature = "sync_once_unwind_safe", since = "1.59.0")] impl UnwindSafe for Once {} +#[stable(feature = "sync_once_unwind_safe", since = "1.59.0")] +impl RefUnwindSafe for Once {} + /// State yielded to [`Once::call_once_force()`]’s closure parameter. The state /// can be used to query the poison status of the [`Once`]. #[stable(feature = "once_poison", since = "1.51.0")]