@@ -42,7 +42,8 @@ macro_rules! impl_error_chain_processed {
4242 }
4343
4444 links {
45- $( $link_variant: ident ( $link_error_path: path, $link_kind_path: path )
45+ $( $link_variant: ident ( $link_error_path: path, $link_kind_path: path,
46+ $link_trait_path: path )
4647 $( #[ $meta_links: meta] ) * ; ) *
4748 }
4849
@@ -70,7 +71,8 @@ macro_rules! impl_error_chain_processed {
7071 /// internals, containing:
7172 /// - a backtrace, generated when the error is created.
7273 /// - an error chain, used for the implementation of `Error::cause()`.
73- #[ derive( Debug , $( $derive) ,* ) ]
74+ //#[derive(Debug, $($derive),*)]
75+ #[ derive( Debug ) ]
7476 pub struct $error_name(
7577 // The members must be `pub` for `links`.
7678 /// The kind of the error.
@@ -148,7 +150,7 @@ macro_rules! impl_error_chain_processed {
148150 }
149151
150152 /// Construct a chained error from another boxed error and a kind, and generates a backtrace
151- pub fn with_boxed_chain<K >( error: Box <:: std :: error :: Error + Send >, kind: K )
153+ pub fn with_boxed_chain<K >( error: Box <Trait >, kind: K )
152154 -> $error_name
153155 where K : Into <$error_kind_name>
154156 {
@@ -222,7 +224,7 @@ macro_rules! impl_error_chain_processed {
222224 fn from( e: $link_error_path) -> Self {
223225 $error_name(
224226 $error_kind_name:: $link_variant( e. 0 ) ,
225- e. 1 ,
227+ :: State { next_error : e. 1 . next_error . map ( |e| $crate :: ConvertErrorTrait :: convert ( e ) ) , backtrace : e . 1 . backtrace } ,
226228 )
227229 }
228230 }
@@ -332,7 +334,7 @@ macro_rules! impl_error_chain_processed {
332334 EK : Into <$error_kind_name>;
333335 }
334336
335- impl <T , E > $result_ext_name<T , E > for :: std:: result:: Result <T , E >
337+ impl <T , E > $result_ext_name<T > for :: std:: result:: Result <T , E >
336338 where E : Trait + ' static
337339 {
338340 fn chain_err<F , EK >( self , callback: F ) -> :: std:: result:: Result <T , $error_name>
@@ -354,8 +356,6 @@ macro_rules! impl_error_chain_processed {
354356 } )
355357 }
356358 }
357-
358-
359359 } ;
360360}
361361
@@ -440,9 +440,21 @@ macro_rules! error_chain {
440440#[ doc( hidden) ]
441441macro_rules! create_super_trait {
442442 ( $name: ident: $bound_1: path, $( $rest: path) ,* ) => {
443- trait $name: $bound_1 $( + $rest) * { }
443+ pub trait $name: $bound_1 $( + $rest) * { }
444444 impl <T : $bound_1 $( + $rest) * > $name for T { }
445- } ;
445+
446+ pub trait ConvertErrorTrait {
447+ type Target : ?Sized ;
448+ fn convert( self : Box <Self >) -> Box <Self :: Target >;
449+ }
450+
451+ impl <T : ?Sized + $bound_1 $( + $rest) * > ConvertErrorTrait for T {
452+ type Target = Trait + ' static ;
453+ fn convert( self : Box <Self >) -> Box <Self :: Target > {
454+ Box :: new( self ) as Box <Trait >
455+ }
456+ }
457+ } ;
446458}
447459
448460/// Macro used to manage the `backtrace` feature.
0 commit comments