Skip to content

Commit 6e60b8a

Browse files
committed
2 parents 38f2324 + c9260c7 commit 6e60b8a

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/error_chain.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ macro_rules! impl_error_chain_processed {
8787

8888
fn with_chain<E, K>(error: E, kind: K)
8989
-> Self
90-
where E: ::std::error::Error + Send + 'static,
90+
where E: ::std::error::Error + Send + Sync + 'static,
9191
K: Into<Self::ErrorKind>
9292
{
9393
Self::with_chain(error, kind)
@@ -129,14 +129,14 @@ macro_rules! impl_error_chain_processed {
129129
/// Constructs a chained error from another error and a kind, and generates a backtrace.
130130
pub fn with_chain<E, K>(error: E, kind: K)
131131
-> $error_name
132-
where E: ::std::error::Error + Send + 'static,
132+
where E: ::std::error::Error + Send + Sync + 'static,
133133
K: Into<$error_kind_name>
134134
{
135135
$error_name::with_boxed_chain(Box::new(error), kind)
136136
}
137137

138138
/// Construct a chained error from another boxed error and a kind, and generates a backtrace
139-
pub fn with_boxed_chain<K>(error: Box<::std::error::Error + Send>, kind: K)
139+
pub fn with_boxed_chain<K>(error: Box<::std::error::Error + Send + Sync>, kind: K)
140140
-> $error_name
141141
where K: Into<$error_kind_name>
142142
{
@@ -320,7 +320,7 @@ macro_rules! impl_error_chain_processed {
320320
EK: Into<$error_kind_name>;
321321
}
322322

323-
impl<T, E> $result_ext_name<T> for ::std::result::Result<T, E> where E: ::std::error::Error + Send + 'static {
323+
impl<T, E> $result_ext_name<T> for ::std::result::Result<T, E> where E: ::std::error::Error + Send + Sync + 'static {
324324
fn chain_err<F, EK>(self, callback: F) -> ::std::result::Result<T, $error_name>
325325
where F: FnOnce() -> EK,
326326
EK: Into<$error_kind_name> {

src/example_generated.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,20 @@ error_chain! {
3636
Custom
3737
}
3838
}
39+
40+
#[cfg(test)]
41+
mod test {
42+
43+
use super::Error;
44+
45+
#[test]
46+
fn generated_error_meets_bounds() {
47+
fn is_sync<T: Sync>() { }
48+
fn is_send<T: Send>() { }
49+
fn is_static<T: 'static>() { }
50+
is_sync::<Error>();
51+
is_send::<Error>();
52+
is_static::<Error>();
53+
assert!(true);
54+
}
55+
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ mod error_chain;
546546
#[macro_use]
547547
mod quick_main;
548548
pub use quick_main::ExitCode;
549-
#[cfg(feature = "example_generated")]
549+
#[cfg(any(test, feature = "example_generated"))]
550550
pub mod example_generated;
551551
mod backtrace;
552552
pub use backtrace::Backtrace;
@@ -590,7 +590,7 @@ pub trait ChainedError: error::Error + Send + 'static {
590590
/// Constructs a chained error from another error and a kind, and generates a backtrace.
591591
fn with_chain<E, K>(error: E, kind: K) -> Self
592592
where Self: Sized,
593-
E: ::std::error::Error + Send + 'static,
593+
E: ::std::error::Error + Send + Sync + 'static,
594594
K: Into<Self::ErrorKind>;
595595

596596
/// Returns the kind of the error.
@@ -654,7 +654,7 @@ impl<'a, T> fmt::Display for DisplayChain<'a, T>
654654
#[doc(hidden)]
655655
pub struct State {
656656
/// Next error in the error chain.
657-
pub next_error: Option<Box<error::Error + Send>>,
657+
pub next_error: Option<Box<error::Error + Send + Sync>>,
658658
/// Backtrace for the current error.
659659
pub backtrace: InternalBacktrace,
660660
}
@@ -670,7 +670,7 @@ impl Default for State {
670670

671671
impl State {
672672
/// Creates a new State type
673-
pub fn new<CE: ChainedError>(e: Box<error::Error + Send>) -> State {
673+
pub fn new<CE: ChainedError>(e: Box<error::Error + Send + Sync>) -> State {
674674
let backtrace = CE::extract_backtrace(&*e)
675675
.unwrap_or_else(InternalBacktrace::new);
676676
State {

0 commit comments

Comments
 (0)