Skip to content

Commit 8e47e43

Browse files
committedSep 15, 2022
always implement unwind safe
1 parent 8ec240e commit 8e47e43

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Increase minimal supported Rust version to 1.56.0.
6+
- Implement `UnwindSafe` even if the `std` feature is disabled.
67

78
## 1.14.0
89

‎src/lib.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,9 @@ pub mod unsync {
348348
cell::{Cell, UnsafeCell},
349349
fmt, hint, mem,
350350
ops::{Deref, DerefMut},
351+
panic::{RefUnwindSafe, UnwindSafe},
351352
};
352353

353-
#[cfg(feature = "std")]
354-
use std::panic::{RefUnwindSafe, UnwindSafe};
355-
356354
/// A cell which can be written to only once. It is not thread safe.
357355
///
358356
/// Unlike [`std::cell::RefCell`], a `OnceCell` provides simple `&`
@@ -382,9 +380,7 @@ pub mod unsync {
382380
// `&unsync::OnceCell` to sneak a `T` through `catch_unwind`,
383381
// by initializing the cell in closure and extracting the value in the
384382
// `Drop`.
385-
#[cfg(feature = "std")]
386383
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceCell<T> {}
387-
#[cfg(feature = "std")]
388384
impl<T: UnwindSafe> UnwindSafe for OnceCell<T> {}
389385

390386
impl<T> Default for OnceCell<T> {
@@ -680,7 +676,6 @@ pub mod unsync {
680676
init: Cell<Option<F>>,
681677
}
682678

683-
#[cfg(feature = "std")]
684679
impl<T, F: RefUnwindSafe> RefUnwindSafe for Lazy<T, F> where OnceCell<T>: RefUnwindSafe {}
685680

686681
impl<T: fmt::Debug, F> fmt::Debug for Lazy<T, F> {
@@ -1225,7 +1220,6 @@ pub mod sync {
12251220
unsafe impl<T, F: Send> Sync for Lazy<T, F> where OnceCell<T>: Sync {}
12261221
// auto-derived `Send` impl is OK.
12271222

1228-
#[cfg(feature = "std")]
12291223
impl<T, F: RefUnwindSafe> RefUnwindSafe for Lazy<T, F> where OnceCell<T>: RefUnwindSafe {}
12301224

12311225
impl<T, F> Lazy<T, F> {

0 commit comments

Comments
 (0)
Please sign in to comment.