Skip to content

Commit f832203

Browse files
committed
Implement RefUnwindSafe for atomic types
Closes #37136
1 parent 40cd1fd commit f832203

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/libstd/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
#![feature(associated_consts)]
219219
#![feature(borrow_state)]
220220
#![feature(box_syntax)]
221+
#![feature(cfg_target_has_atomic)]
221222
#![feature(cfg_target_thread_local)]
222223
#![feature(cfg_target_vendor)]
223224
#![feature(char_escape_debug)]
@@ -239,6 +240,7 @@
239240
#![feature(heap_api)]
240241
#![feature(inclusive_range)]
241242
#![feature(int_error_internals)]
243+
#![feature(integer_atomics)]
242244
#![feature(into_cow)]
243245
#![feature(lang_items)]
244246
#![feature(libc)]

src/libstd/panic.rs

+41-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ops::{Deref, DerefMut};
1818
use panicking;
1919
use ptr::{Unique, Shared};
2020
use rc::Rc;
21-
use sync::{Arc, Mutex, RwLock};
21+
use sync::{Arc, Mutex, RwLock, atomic};
2222
use thread::Result;
2323

2424
#[stable(feature = "panic_hooks", since = "1.10.0")]
@@ -231,6 +231,46 @@ impl<T: ?Sized> RefUnwindSafe for Mutex<T> {}
231231
#[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")]
232232
impl<T: ?Sized> RefUnwindSafe for RwLock<T> {}
233233

234+
#[cfg(target_has_atomic = "ptr")]
235+
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
236+
impl RefUnwindSafe for atomic::AtomicIsize {}
237+
#[cfg(target_has_atomic = "8")]
238+
#[unstable(feature = "integer_atomics", issue = "32976")]
239+
impl RefUnwindSafe for atomic::AtomicI8 {}
240+
#[cfg(target_has_atomic = "16")]
241+
#[unstable(feature = "integer_atomics", issue = "32976")]
242+
impl RefUnwindSafe for atomic::AtomicI16 {}
243+
#[cfg(target_has_atomic = "32")]
244+
#[unstable(feature = "integer_atomics", issue = "32976")]
245+
impl RefUnwindSafe for atomic::AtomicI32 {}
246+
#[cfg(target_has_atomic = "64")]
247+
#[unstable(feature = "integer_atomics", issue = "32976")]
248+
impl RefUnwindSafe for atomic::AtomicI64 {}
249+
250+
#[cfg(target_has_atomic = "ptr")]
251+
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
252+
impl RefUnwindSafe for atomic::AtomicUsize {}
253+
#[cfg(target_has_atomic = "8")]
254+
#[unstable(feature = "integer_atomics", issue = "32976")]
255+
impl RefUnwindSafe for atomic::AtomicU8 {}
256+
#[cfg(target_has_atomic = "16")]
257+
#[unstable(feature = "integer_atomics", issue = "32976")]
258+
impl RefUnwindSafe for atomic::AtomicU16 {}
259+
#[cfg(target_has_atomic = "32")]
260+
#[unstable(feature = "integer_atomics", issue = "32976")]
261+
impl RefUnwindSafe for atomic::AtomicU32 {}
262+
#[cfg(target_has_atomic = "64")]
263+
#[unstable(feature = "integer_atomics", issue = "32976")]
264+
impl RefUnwindSafe for atomic::AtomicU64 {}
265+
266+
#[cfg(target_has_atomic = "8")]
267+
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
268+
impl RefUnwindSafe for atomic::AtomicBool {}
269+
270+
#[cfg(target_has_atomic = "ptr")]
271+
#[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
272+
impl<T> RefUnwindSafe for atomic::AtomicPtr<T> {}
273+
234274
#[stable(feature = "catch_unwind", since = "1.9.0")]
235275
impl<T> Deref for AssertUnwindSafe<T> {
236276
type Target = T;

0 commit comments

Comments
 (0)