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

Commit 7f168a2

Browse files
committed
Fix create_super_trait macro not accepting paths to traits
Re-order the derive block internally
1 parent 2b09834 commit 7f168a2

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
@@ -39,10 +39,6 @@ macro_rules! error_chain_processed {
3939
$result_ext_name:ident;
4040
}
4141

42-
derive {
43-
$($bound:ident),*
44-
}
45-
4642
links {
4743
$( $link_variant:ident ( $link_error_path:path, $link_kind_path:path )
4844
$( #[$meta_links:meta] )*; ) *
@@ -57,10 +53,11 @@ macro_rules! error_chain_processed {
5753
$( $error_chunks:tt ) *
5854
}
5955

56+
derive {
57+
$($bound:ident),*
58+
}
6059
) => {
61-
use ::std::fmt::Debug;
62-
use ::std::error::Error as StdError;
63-
create_super_trait!(Trait: Debug, StdError, Send $(, $bound)*);
60+
create_super_trait!(Trait: ::std::fmt::Debug, ::std::error::Error, Send $(, $bound)*);
6461

6562
/// The Error type.
6663
///
@@ -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
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
}
@@ -435,12 +432,9 @@ macro_rules! error_chain {
435432
#[macro_export]
436433
#[doc(hidden)]
437434
macro_rules! create_super_trait {
438-
($name:ident: $($bound:ident),*) => {
439-
create_super_trait!($name: $($bound +)*);
440-
};
441-
($name:ident: $bound_1:ident + $($bound_2:tt +)*) => {
442-
trait $name: $bound_1 $(+ $bound_2)* {}
443-
impl<T: $bound_1 $(+ $bound_2)*> $name for T {}
435+
($name:ident: $bound_1:path, $($rest:path),*) => {
436+
trait $name: $bound_1 $(+ $rest)* {}
437+
impl<T: $bound_1 $(+ $rest)*> $name for T {}
444438
};
445439
}
446440

0 commit comments

Comments
 (0)