@@ -54,10 +54,10 @@ macro_rules! error_chain_processed {
5454        } 
5555
5656        derive { 
57-             $( $bound : ident) , * 
57+             $( $derive : ident,  $bound : path ) ; * 
5858        } 
5959    )  => { 
60-         create_super_trait!( Trait :  :: std:: fmt:: Debug ,  :: std:: error:: Error ,  Send  $( ,  $bound) * ) ; 
60+         create_super_trait!( Trait :  :: std:: fmt:: Debug ,  :: std:: error:: Error ,  $crate :: ToError   ,   Send  $( ,  $bound) * ) ; 
6161
6262        /// The Error type. 
6363/// 
@@ -68,7 +68,7 @@ macro_rules! error_chain_processed {
6868///   internals, containing: 
6969///   - a backtrace, generated when the error is created. 
7070///   - an error chain, used for the implementation of `Error::cause()`. 
71- [ derive( Debug ,  $( $bound ) ,* ) ] 
71+ [ derive( Debug ,  $( $derive ) ,* ) ] 
7272        pub  struct  $error_name( 
7373            // The members must be `pub` for `links`. 
7474            /// The kind of the error. 
@@ -78,6 +78,12 @@ macro_rules! error_chain_processed {
7878            pub  $crate:: State <Trait >, 
7979        ) ; 
8080
81+         impl  $crate:: ToError  for  $error_name { 
82+             fn  to_error( & self )  -> & ( :: std:: error:: Error  + Send  + ' static )  { 
83+                 self 
84+             } 
85+         } 
86+ 
8187        impl  $crate:: ChainedError <Trait > for  $error_name { 
8288            type  ErrorKind  = $error_kind_name; 
8389
@@ -91,7 +97,7 @@ macro_rules! error_chain_processed {
9197
9298            fn  with_chain<E ,  K >( error:  E ,  kind:  K ) 
9399                -> Self 
94-                 where  E :  :: std:: error:: Error  + Send  + ' static , 
100+                 where  E :  $crate :: ToError  +  :: std:: error:: Error  + Send  + ' static , 
95101                      K :  Into <Self :: ErrorKind >
96102            { 
97103                Self :: with_chain( error,  kind) 
@@ -133,7 +139,7 @@ macro_rules! error_chain_processed {
133139            /// Constructs a chained error from another error and a kind, and generates a backtrace. 
134140pub  fn  with_chain<E ,  K >( error:  E ,  kind:  K ) 
135141                -> $error_name
136-                 where  E :  :: std :: error :: Error  +  Send  + ' static , 
142+                 where  E :  Trait  + ' static , 
137143                      K :  Into <$error_kind_name>
138144            { 
139145                $error_name:: with_boxed_chain( Box :: new( error) ,  kind) 
@@ -180,7 +186,7 @@ macro_rules! error_chain_processed {
180186            #[ allow( unknown_lints,  unused_doc_comment) ] 
181187            fn  cause( & self )  -> Option <& :: std:: error:: Error > { 
182188                match  self . 1 . next_error { 
183-                     Some ( ref c)  => Some ( & * * c ) , 
189+                     Some ( ref c)  => Some ( c . to_error ( ) ) , 
184190                    None  => { 
185191                        match  self . 0  { 
186192                            $( 
@@ -257,7 +263,7 @@ macro_rules! error_chain_processed {
257263
258264        quick_error! { 
259265            /// The kind of an error. 
260- [ derive( Debug ,  $( $bound ) ,* ) ] 
266+ [ derive( Debug ,  $( $derive ) ,* ) ] 
261267            pub  enum  $error_kind_name { 
262268
263269                /// A convenient variant for String. 
@@ -326,12 +332,18 @@ macro_rules! error_chain_processed {
326332                      EK :  Into <$error_kind_name>; 
327333        } 
328334
335+ <<<<<<< HEAD 
329336        impl <T ,  E > $result_ext_name<T > for  :: std:: result:: Result <T ,  E > where  E :  :: std:: error:: Error  + Send  + ' static  { 
337+ =======
338+         impl <T ,  E > $result_ext_name<T ,  E > for  :: std:: result:: Result <T ,  E >
339+             where  E :  Trait  + ' static 
340+         { 
341+ >>>>>>> Change  `derive` block to take the derive macro name and path to the trait 
330342            fn  chain_err<F ,  EK >( self ,  callback:  F )  -> :: std:: result:: Result <T ,  $error_name>
331343                where  F :  FnOnce ( )  -> EK , 
332344                      EK :  Into <$error_kind_name> { 
333345                self . map_err( move |e| { 
334-                     let  state = $crate:: State :: new:: <$error_name>( Box :: new( e) ,   ) ; 
346+                     let  state = $crate:: State :: new:: <$error_name>( Box :: new( e) ) ; 
335347                    $crate:: ChainedError :: new( callback( ) . into( ) ,  state) 
336348                } ) 
337349            } 
0 commit comments