@@ -292,7 +292,7 @@ macro_rules! quick_error {
292292 => $iitem: $imode [ $( $ivar: $ityp ) ,* ] ) * ]
293293 ) ;
294294 quick_error!( IMPLEMENTATIONS $name { $(
295- $iitem: $imode [ $( $ivar: $ityp ) ,* ] { $( $ifuncs ) * }
295+ $iitem: $imode [ $( # [ $imeta ] ) * ] [ $ ( $ivar: $ityp ) ,* ] { $( $ifuncs ) * }
296296 ) * } ) ;
297297 $(
298298 quick_error!( ERROR_CHECK $imode $( $ifuncs) * ) ;
@@ -311,7 +311,7 @@ macro_rules! quick_error {
311311 => $iitem: $imode [ $( $ivar: $ityp ) ,* ] ) * ]
312312 ) ;
313313 quick_error!( IMPLEMENTATIONS $name { $(
314- $iitem: $imode [ $( $ivar: $ityp ) ,* ] { $( $ifuncs ) * }
314+ $iitem: $imode [ $( # [ $imeta ] ) * ] [ $ ( $ivar: $ityp ) ,* ] { $( $ifuncs ) * }
315315 ) * } ) ;
316316 $(
317317 quick_error!( ERROR_CHECK $imode $( $ifuncs) * ) ;
@@ -516,7 +516,7 @@ macro_rules! quick_error {
516516 } ;
517517 ( IMPLEMENTATIONS
518518 $name: ident { $(
519- $item: ident: $imode: tt [ $( $var: ident: $typ: ty ) ,* ] { $( $funcs: tt ) * }
519+ $item: ident: $imode: tt [ $( # [ $imeta : meta ] ) * ] [ $ ( $var: ident: $typ: ty ) ,* ] { $( $funcs: tt ) * }
520520 ) * }
521521 ) => {
522522 #[ allow( unused) ]
@@ -526,6 +526,7 @@ macro_rules! quick_error {
526526 {
527527 match * self {
528528 $(
529+ $( #[ $imeta] ) *
529530 quick_error!( ITEM_PATTERN
530531 $name $item: $imode [ $( ref $var ) ,* ]
531532 ) => {
@@ -544,6 +545,7 @@ macro_rules! quick_error {
544545 fn description( & self ) -> & str {
545546 match * self {
546547 $(
548+ $( #[ $imeta] ) *
547549 quick_error!( ITEM_PATTERN
548550 $name $item: $imode [ $( ref $var ) ,* ]
549551 ) => {
@@ -557,6 +559,7 @@ macro_rules! quick_error {
557559 fn cause( & self ) -> Option <& :: std:: error:: Error > {
558560 match * self {
559561 $(
562+ $( #[ $imeta] ) *
560563 quick_error!( ITEM_PATTERN
561564 $name $item: $imode [ $( ref $var ) ,* ]
562565 ) => {
@@ -1131,4 +1134,16 @@ mod test {
11311134 "Path error at \" /tmp\" : invalid utf-8: \
11321135 invalid byte near index 0") ;
11331136 }
1137+
1138+ #[ test]
1139+ fn conditional_compilation ( ) {
1140+ quick_error ! {
1141+ #[ allow( dead_code) ]
1142+ #[ derive( Debug ) ]
1143+ pub enum Test {
1144+ #[ cfg( feature = "foo" ) ]
1145+ Variant
1146+ }
1147+ }
1148+ }
11341149}
0 commit comments