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

Commit

Permalink
Fix create_super_trait macro not accepting paths to traits
Browse files Browse the repository at this point in the history
Re-order the derive block internally
  • Loading branch information
pengowen123 committed Jul 2, 2017
1 parent 635aa19 commit 6a44d4b
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions src/error_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ macro_rules! error_chain_processed {
$result_ext_name:ident;
}

derive {
$($bound:ident),*
}

links {
$( $link_variant:ident ( $link_error_path:path, $link_kind_path:path )
$( #[$meta_links:meta] )*; ) *
Expand All @@ -57,10 +53,11 @@ macro_rules! error_chain_processed {
$( $error_chunks:tt ) *
}

derive {
$($bound:ident),*
}
) => {
use ::std::fmt::Debug;
use ::std::error::Error as StdError;
create_super_trait!(Trait: Debug, StdError, Send $(, $bound)*);
create_super_trait!(Trait: ::std::fmt::Debug, ::std::error::Error, Send $(, $bound)*);

/// The Error type.
///
Expand Down Expand Up @@ -351,7 +348,7 @@ macro_rules! error_chain_processing {
};
(
($a:tt, {}, $c:tt, $d:tt, $e:tt)
derive $content:tt
links $content:tt
$( $tail:tt )*
) => {
error_chain_processing! {
Expand All @@ -361,7 +358,7 @@ macro_rules! error_chain_processing {
};
(
($a:tt, $b:tt, {}, $d:tt, $e:tt)
links $content:tt
foreign_links $content:tt
$( $tail:tt )*
) => {
error_chain_processing! {
Expand All @@ -371,7 +368,7 @@ macro_rules! error_chain_processing {
};
(
($a:tt, $b:tt, $c:tt, {}, $e:tt)
foreign_links $content:tt
errors $content:tt
$( $tail:tt )*
) => {
error_chain_processing! {
Expand All @@ -381,7 +378,7 @@ macro_rules! error_chain_processing {
};
(
($a:tt, $b:tt, $c:tt, $d:tt, {})
errors $content:tt
derive $content:tt
$( $tail:tt )*
) => {
error_chain_processing! {
Expand All @@ -392,10 +389,10 @@ macro_rules! error_chain_processing {
( ($a:tt, $b:tt, $c:tt, $d:tt, $e:tt) ) => {
error_chain_processed! {
types $a
derive $b
links $c
foreign_links $d
errors $e
links $b
foreign_links $c
errors $d
derive $e
}
};
}
Expand All @@ -416,12 +413,9 @@ macro_rules! error_chain {
#[macro_export]
#[doc(hidden)]
macro_rules! create_super_trait {
($name:ident: $($bound:ident),*) => {
create_super_trait!($name: $($bound +)*);
};
($name:ident: $bound_1:ident + $($bound_2:tt +)*) => {
trait $name: $bound_1 $(+ $bound_2)* {}
impl<T: $bound_1 $(+ $bound_2)*> $name for T {}
($name:ident: $bound_1:path, $($rest:path),*) => {
trait $name: $bound_1 $(+ $rest)* {}
impl<T: $bound_1 $(+ $rest)*> $name for T {}
};
}

Expand Down

0 comments on commit 6a44d4b

Please sign in to comment.