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

Commit 6a44d4b

Browse files
committed
Fix create_super_trait macro not accepting paths to traits
Re-order the derive block internally
1 parent 635aa19 commit 6a44d4b

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/error_chain.rs

Lines changed: 15 additions & 21 deletions
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
///
@@ -351,7 +348,7 @@ macro_rules! error_chain_processing {
351348
};
352349
(
353350
($a:tt, {}, $c:tt, $d:tt, $e:tt)
354-
derive $content:tt
351+
links $content:tt
355352
$( $tail:tt )*
356353
) => {
357354
error_chain_processing! {
@@ -361,7 +358,7 @@ macro_rules! error_chain_processing {
361358
};
362359
(
363360
($a:tt, $b:tt, {}, $d:tt, $e:tt)
364-
links $content:tt
361+
foreign_links $content:tt
365362
$( $tail:tt )*
366363
) => {
367364
error_chain_processing! {
@@ -371,7 +368,7 @@ macro_rules! error_chain_processing {
371368
};
372369
(
373370
($a:tt, $b:tt, $c:tt, {}, $e:tt)
374-
foreign_links $content:tt
371+
errors $content:tt
375372
$( $tail:tt )*
376373
) => {
377374
error_chain_processing! {
@@ -381,7 +378,7 @@ macro_rules! error_chain_processing {
381378
};
382379
(
383380
($a:tt, $b:tt, $c:tt, $d:tt, {})
384-
errors $content:tt
381+
derive $content:tt
385382
$( $tail:tt )*
386383
) => {
387384
error_chain_processing! {
@@ -392,10 +389,10 @@ macro_rules! error_chain_processing {
392389
( ($a:tt, $b:tt, $c:tt, $d:tt, $e:tt) ) => {
393390
error_chain_processed! {
394391
types $a
395-
derive $b
396-
links $c
397-
foreign_links $d
398-
errors $e
392+
links $b
393+
foreign_links $c
394+
errors $d
395+
derive $e
399396
}
400397
};
401398
}
@@ -416,12 +413,9 @@ macro_rules! error_chain {
416413
#[macro_export]
417414
#[doc(hidden)]
418415
macro_rules! create_super_trait {
419-
($name:ident: $($bound:ident),*) => {
420-
create_super_trait!($name: $($bound +)*);
421-
};
422-
($name:ident: $bound_1:ident + $($bound_2:tt +)*) => {
423-
trait $name: $bound_1 $(+ $bound_2)* {}
424-
impl<T: $bound_1 $(+ $bound_2)*> $name for T {}
416+
($name:ident: $bound_1:path, $($rest:path),*) => {
417+
trait $name: $bound_1 $(+ $rest)* {}
418+
impl<T: $bound_1 $(+ $rest)*> $name for T {}
425419
};
426420
}
427421

0 commit comments

Comments
 (0)