Actually re-establish and assert Syncness of Error. (98affbdeaf)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -8,17 +8,18 @@ use std::{
|
||||
any::Any,
|
||||
borrow::Cow,
|
||||
convert::Infallible,
|
||||
sync::{OnceLock, PoisonError},
|
||||
sync::{Mutex, PoisonError},
|
||||
};
|
||||
|
||||
pub use self::{err::visit, log::*};
|
||||
use crate::utils::{assert_ref_unwind_safe, assert_send, assert_sync, assert_unwind_safe};
|
||||
|
||||
#[derive(thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("PANIC!")]
|
||||
PanicAny(OnceLock<Box<dyn Any + Send>>),
|
||||
PanicAny(Mutex<Box<dyn Any + Send>>),
|
||||
#[error("PANIC! {0}")]
|
||||
Panic(&'static str, OnceLock<Box<dyn Any + Send + 'static>>),
|
||||
Panic(&'static str, Mutex<Box<dyn Any + Send + 'static>>),
|
||||
|
||||
// std
|
||||
#[error(transparent)]
|
||||
@@ -141,6 +142,11 @@ pub enum Error {
|
||||
Err(Cow<'static, str>),
|
||||
}
|
||||
|
||||
static _IS_SEND: () = assert_send::<Error>();
|
||||
static _IS_SYNC: () = assert_sync::<Error>();
|
||||
static _IS_UNWIND_SAFE: () = assert_unwind_safe::<Error>();
|
||||
static _IS_REF_UNWIND_SAFE: () = assert_ref_unwind_safe::<Error>();
|
||||
|
||||
impl Error {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
|
||||
@@ -23,8 +23,8 @@ impl Error {
|
||||
pub fn into_panic(self) -> Box<dyn Any + Send> {
|
||||
match self {
|
||||
| Self::JoinError(e) => e.into_panic(),
|
||||
| Self::Panic(_, mut e) | Self::PanicAny(mut e) =>
|
||||
e.take().expect("Error contained panic"),
|
||||
| Self::Panic(_, e) | Self::PanicAny(e) =>
|
||||
e.into_inner().expect("Error contained panic"),
|
||||
| _ => Box::new(self),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user