Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 24c9538

Browse files
committed
Fix create_super_trait macro not accepting paths to traits
Re-order the derive block internally
1 parent 85a6930 commit 24c9538

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/error_chain.rs

+15-21
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ macro_rules! impl_error_chain_processed {
4141
$result_ext_name:ident;
4242
}
4343

44-
derive {
45-
$($bound:ident),*
46-
}
47-
4844
links {
4945
$( $link_variant:ident ( $link_error_path:path, $link_kind_path:path )
5046
$( #[$meta_links:meta] )*; ) *
@@ -59,10 +55,11 @@ macro_rules! impl_error_chain_processed {
5955
$( $error_chunks:tt ) *
6056
}
6157

58+
derive {
59+
$($bound:ident),*
60+
}
6261
) => {
63-
use ::std::fmt::Debug;
64-
use ::std::error::Error as StdError;
65-
create_super_trait!(Trait: Debug, StdError, Send $(, $bound)*);
62+
create_super_trait!(Trait: ::std::fmt::Debug, ::std::error::Error, Send $(, $bound)*);
6663

6764
/// The Error type.
6865
///
@@ -370,7 +367,7 @@ macro_rules! error_chain_processing {
370367
};
371368
(
372369
($a:tt, {}, $c:tt, $d:tt, $e:tt)
373-
derive $content:tt
370+
links $content:tt
374371
$( $tail:tt )*
375372
) => {
376373
error_chain_processing! {
@@ -380,7 +377,7 @@ macro_rules! error_chain_processing {
380377
};
381378
(
382379
($a:tt, $b:tt, {}, $d:tt, $e:tt)
383-
links $content:tt
380+
foreign_links $content:tt
384381
$( $tail:tt )*
385382
) => {
386383
error_chain_processing! {
@@ -390,7 +387,7 @@ macro_rules! error_chain_processing {
390387
};
391388
(
392389
($a:tt, $b:tt, $c:tt, {}, $e:tt)
393-
foreign_links $content:tt
390+
errors $content:tt
394391
$( $tail:tt )*
395392
) => {
396393
error_chain_processing! {
@@ -400,7 +397,7 @@ macro_rules! error_chain_processing {
400397
};
401398
(
402399
($a:tt, $b:tt, $c:tt, $d:tt, {})
403-
errors $content:tt
400+
derive $content:tt
404401
$( $tail:tt )*
405402
) => {
406403
error_chain_processing! {
@@ -411,10 +408,10 @@ macro_rules! error_chain_processing {
411408
( ($a:tt, $b:tt, $c:tt, $d:tt, $e:tt) ) => {
412409
impl_error_chain_processed! {
413410
types $a
414-
derive $b
415-
links $c
416-
foreign_links $d
417-
errors $e
411+
links $b
412+
foreign_links $c
413+
errors $d
414+
derive $e
418415
}
419416
};
420417
}
@@ -434,12 +431,9 @@ macro_rules! error_chain {
434431
#[macro_export]
435432
#[doc(hidden)]
436433
macro_rules! create_super_trait {
437-
($name:ident: $($bound:ident),*) => {
438-
create_super_trait!($name: $($bound +)*);
439-
};
440-
($name:ident: $bound_1:ident + $($bound_2:tt +)*) => {
441-
trait $name: $bound_1 $(+ $bound_2)* {}
442-
impl<T: $bound_1 $(+ $bound_2)*> $name for T {}
434+
($name:ident: $bound_1:path, $($rest:path),*) => {
435+
trait $name: $bound_1 $(+ $rest)* {}
436+
impl<T: $bound_1 $(+ $rest)*> $name for T {}
443437
};
444438
}
445439

0 commit comments

Comments
 (0)