Skip to content

Commit

Permalink
Requires that errors are Send/Sync/'static (apply PR rust-lang-deprec…
Browse files Browse the repository at this point in the history
  • Loading branch information
efenniht-furiosa committed May 26, 2020
1 parent 9a41c0d commit 4f5c37e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/error_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ macro_rules! impl_error_chain_processed {

fn with_chain<E, K>(error: E, kind: K)
-> Self
where E: ::std::error::Error + Send + 'static,
where E: ::std::error::Error + Send + Sync + 'static,
K: Into<Self::ErrorKind>
{
Self::with_chain(error, kind)
Expand Down Expand Up @@ -273,15 +273,15 @@ macro_rules! impl_error_chain_processed {
/// Constructs a chained error from another error and a kind, and generates a backtrace.
pub fn with_chain<E, K>(error: E, kind: K)
-> $error_name
where E: ::std::error::Error + Send + 'static,
where E: ::std::error::Error + Send + Sync + 'static,
K: Into<$error_kind_name>
{
$error_name::with_boxed_chain(Box::new(error), kind)
}

/// Construct a chained error from another boxed error and a kind, and generates a backtrace
#[allow(unknown_lints, bare_trait_objects)]
pub fn with_boxed_chain<K>(error: Box<::std::error::Error + Send>, kind: K)
pub fn with_boxed_chain<K>(error: Box<::std::error::Error + Send + Sync>, kind: K)
-> $error_name
where K: Into<$error_kind_name>
{
Expand Down Expand Up @@ -426,7 +426,7 @@ macro_rules! impl_error_chain_processed {
EK: Into<$error_kind_name>;
}

impl<T, E> $result_ext_name<T> for ::std::result::Result<T, E> where E: ::std::error::Error + Send + 'static {
impl<T, E> $result_ext_name<T> for ::std::result::Result<T, E> where E: ::std::error::Error + Send + Sync + 'static {
fn chain_err<F, EK>(self, callback: F) -> ::std::result::Result<T, $error_name>
where F: FnOnce() -> EK,
EK: Into<$error_kind_name> {
Expand Down Expand Up @@ -545,7 +545,7 @@ macro_rules! impl_extract_backtrace {
$([$link_error_path: path, $(#[$meta_links: meta])*])*) => {
#[allow(unknown_lints, renamed_and_removed_lints, bare_trait_objects)]
#[allow(unused_doc_comment, unused_doc_comments)]
fn extract_backtrace(e: &(::std::error::Error + Send + 'static))
fn extract_backtrace(e: &(::std::error::Error + Send + Sync + 'static))
-> Option<$crate::InternalBacktrace> {
if let Some(e) = e.downcast_ref::<$error_name>() {
return Some(e.1.backtrace.clone());
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ impl<'a> Iterator for Iter<'a> {

/// This trait is implemented on all the errors generated by the `error_chain`
/// macro.
pub trait ChainedError: error::Error + Send + 'static {
pub trait ChainedError: error::Error + Send + Sync + 'static {
/// Associated kind type.
type ErrorKind;

Expand All @@ -605,7 +605,7 @@ pub trait ChainedError: error::Error + Send + 'static {
fn with_chain<E, K>(error: E, kind: K) -> Self
where
Self: Sized,
E: ::std::error::Error + Send + 'static,
E: ::std::error::Error + Send + Sync + 'static,
K: Into<Self::ErrorKind>;

/// Returns the kind of the error.
Expand Down Expand Up @@ -641,7 +641,7 @@ pub trait ChainedError: error::Error + Send + 'static {
/// of the errors from `foreign_links`.
#[doc(hidden)]
#[allow(unknown_lints, bare_trait_objects)]
fn extract_backtrace(e: &(error::Error + Send + 'static)) -> Option<InternalBacktrace>
fn extract_backtrace(e: &(error::Error + Send + Sync + 'static)) -> Option<InternalBacktrace>
where
Self: Sized;
}
Expand Down Expand Up @@ -675,7 +675,7 @@ where
#[allow(unknown_lints, bare_trait_objects)]
pub struct State {
/// Next error in the error chain.
pub next_error: Option<Box<error::Error + Send>>,
pub next_error: Option<Box<error::Error + Send + Sync>>,
/// Backtrace for the current error.
pub backtrace: InternalBacktrace,
}
Expand All @@ -692,7 +692,7 @@ impl Default for State {
impl State {
/// Creates a new State type
#[allow(unknown_lints, bare_trait_objects)]
pub fn new<CE: ChainedError>(e: Box<error::Error + Send>) -> State {
pub fn new<CE: ChainedError>(e: Box<error::Error + Send + Sync>) -> State {
let backtrace = CE::extract_backtrace(&*e).unwrap_or_else(InternalBacktrace::new);
State {
next_error: Some(e),
Expand Down

0 comments on commit 4f5c37e

Please sign in to comment.