From 96ecaa17a7f333f3c374d5742565087a72798479 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 31 Jul 2021 03:57:49 -0700 Subject: [PATCH] Relocate Arc and Rc UnwindSafe impls --- library/alloc/src/lib.rs | 1 - library/alloc/src/panic.rs | 11 ----------- library/alloc/src/rc.rs | 4 ++++ library/alloc/src/sync.rs | 4 ++++ 4 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 library/alloc/src/panic.rs diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 12a5868db74..d2ececaa975 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -177,7 +177,6 @@ mod boxed { pub mod borrow; pub mod collections; pub mod fmt; -mod panic; pub mod prelude; pub mod raw_vec; pub mod rc; diff --git a/library/alloc/src/panic.rs b/library/alloc/src/panic.rs deleted file mode 100644 index b854be9f5ce..00000000000 --- a/library/alloc/src/panic.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::rc::Rc; -use crate::sync::Arc; -use core::panic::{RefUnwindSafe, UnwindSafe}; - -// not covered via the Shared impl in libcore b/c the inner contents use -// Cell/AtomicUsize, but the usage here is unwind safe so we can lift the -// impl up one level to Arc/Rc itself -#[stable(feature = "catch_unwind", since = "1.9.0")] -impl UnwindSafe for Rc {} -#[stable(feature = "catch_unwind", since = "1.9.0")] -impl UnwindSafe for Arc {} diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index a1787ceac59..0b3079fa59d 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -262,6 +262,7 @@ use core::marker::{self, PhantomData, Unpin, Unsize}; use core::mem::size_of_val; use core::mem::{self, align_of_val_raw, forget}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; +use core::panic::{RefUnwindSafe, UnwindSafe}; #[cfg(not(no_global_oom_handling))] use core::pin::Pin; use core::ptr::{self, NonNull}; @@ -314,6 +315,9 @@ impl !marker::Send for Rc {} #[stable(feature = "rust1", since = "1.0.0")] impl !marker::Sync for Rc {} +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for Rc {} + #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Rc {} diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 78671c4f64e..3183a6db410 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -19,6 +19,7 @@ use core::marker::{PhantomData, Unpin, Unsize}; use core::mem::size_of_val; use core::mem::{self, align_of_val_raw}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; +use core::panic::{RefUnwindSafe, UnwindSafe}; use core::pin::Pin; use core::ptr::{self, NonNull}; #[cfg(not(no_global_oom_handling))] @@ -240,6 +241,9 @@ unsafe impl Send for Arc {} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Sync for Arc {} +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for Arc {} + #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Arc {}