From d0463606f49e80987ee6f5c86c281de056a67124 Mon Sep 17 00:00:00 2001 From: Sanguk Park Date: Tue, 26 May 2020 14:55:39 +0900 Subject: [PATCH] Requires that errors are Send/Sync/'static (apply PR rust-lang-nursery/error-chain#241.) --- src/error_chain.rs | 10 +++++----- src/lib.rs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/error_chain.rs b/src/error_chain.rs index 83827096..799c7cad 100755 --- a/src/error_chain.rs +++ b/src/error_chain.rs @@ -231,7 +231,7 @@ macro_rules! impl_error_chain_processed { fn with_chain(error: E, kind: K) -> Self - where E: ::std::error::Error + Send + 'static, + where E: ::std::error::Error + Send + Sync + 'static, K: Into { Self::with_chain(error, kind) @@ -273,7 +273,7 @@ macro_rules! impl_error_chain_processed { /// Constructs a chained error from another error and a kind, and generates a backtrace. pub fn with_chain(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) @@ -281,7 +281,7 @@ macro_rules! impl_error_chain_processed { /// 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(error: Box<::std::error::Error + Send>, kind: K) + pub fn with_boxed_chain(error: Box<::std::error::Error + Send + Sync>, kind: K) -> $error_name where K: Into<$error_kind_name> { @@ -426,7 +426,7 @@ macro_rules! impl_error_chain_processed { EK: Into<$error_kind_name>; } - impl $result_ext_name for ::std::result::Result where E: ::std::error::Error + Send + 'static { + impl $result_ext_name for ::std::result::Result where E: ::std::error::Error + Send + Sync + 'static { fn chain_err(self, callback: F) -> ::std::result::Result where F: FnOnce() -> EK, EK: Into<$error_kind_name> { @@ -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()); diff --git a/src/lib.rs b/src/lib.rs index b6bd2f27..74b1138d 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; @@ -605,7 +605,7 @@ pub trait ChainedError: error::Error + Send + 'static { fn with_chain(error: E, kind: K) -> Self where Self: Sized, - E: ::std::error::Error + Send + 'static, + E: ::std::error::Error + Send + Sync + 'static, K: Into; /// Returns the kind of the error. @@ -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 + fn extract_backtrace(e: &(error::Error + Send + Sync + 'static)) -> Option where Self: Sized; } @@ -675,7 +675,7 @@ where #[allow(unknown_lints, bare_trait_objects)] pub struct State { /// Next error in the error chain. - pub next_error: Option>, + pub next_error: Option>, /// Backtrace for the current error. pub backtrace: InternalBacktrace, } @@ -692,7 +692,7 @@ impl Default for State { impl State { /// Creates a new State type #[allow(unknown_lints, bare_trait_objects)] - pub fn new(e: Box) -> State { + pub fn new(e: Box) -> State { let backtrace = CE::extract_backtrace(&*e).unwrap_or_else(InternalBacktrace::new); State { next_error: Some(e),