@@ -36,13 +36,13 @@ macro_rules! error_chain_processed {
36
36
}
37
37
38
38
links {
39
- $( $link_variant : ident ( $link_error_path : path )
40
- $( # [ $meta_links : meta ] ) * ; ) *
39
+ $( [ $ ( # [ $meta_links : meta ] ) * ]
40
+ $link_variant : ident ( $link_error_path : path ) ; ) *
41
41
}
42
42
43
43
foreign_links {
44
- $( $foreign_link_variant : ident ( $foreign_link_error_path : path )
45
- $( # [ $meta_foreign_links : meta ] ) * ; ) *
44
+ $( [ $ ( # [ $meta_foreign_links : meta ] ) * ]
45
+ $foreign_link_variant : ident ( $foreign_link_error_path : path ) ; ) *
46
46
}
47
47
48
48
errors {
@@ -251,6 +251,38 @@ macro_rules! error_chain_processed {
251
251
} ;
252
252
}
253
253
254
+ /// Internal macro used for reordering of the fields.
255
+ #[ doc( hidden) ]
256
+ #[ macro_export]
257
+ macro_rules! handle_attributes {
258
+ ( { $( $inner: tt) * } ) => {
259
+ handle_attributes!( [ ] { $( $inner) * } { } )
260
+ } ;
261
+ ( [ $( $attrs: tt) * ]
262
+ { #[ $attr: meta] $( $to_parse: tt ) * }
263
+ { $( $already_parsed: tt ) * } ) => {
264
+ handle_attributes!( [ $( $attrs ) * #[ $attr] ]
265
+ { $( $to_parse ) * }
266
+ { $( $already_parsed ) * } )
267
+ } ;
268
+ ( [ $( $attrs: tt) * ]
269
+ { $name: ident ( $variant: path ) $( $to_parse: tt ) * }
270
+ { $already_parsed: tt } ) => {
271
+ handle_attributes!( [ ]
272
+ { $( $to_parse ) * }
273
+ { $( $already_parsed ) *
274
+ [ $( $attrs ) * ]
275
+ $name ( $variant ) } )
276
+ } ;
277
+ ( [ ]
278
+ { }
279
+ { $( $parsed: tt ) * } ) => {
280
+ {
281
+ $( $parsed ) *
282
+ }
283
+ } ;
284
+ }
285
+
254
286
/// Internal macro used for reordering of the fields.
255
287
#[ doc( hidden) ]
256
288
#[ macro_export]
@@ -261,7 +293,7 @@ macro_rules! error_chain_processing {
261
293
$( $tail: tt ) *
262
294
) => {
263
295
error_chain_processing! {
264
- ( $content, $b, $c, $d)
296
+ ( handle_attributes! ( $content) , $b, $c, $d)
265
297
$( $tail) *
266
298
}
267
299
} ;
@@ -271,7 +303,7 @@ macro_rules! error_chain_processing {
271
303
$( $tail: tt ) *
272
304
) => {
273
305
error_chain_processing! {
274
- ( $a, $content, $c, $d)
306
+ ( $a, handle_attributes! ( $content) , $c, $d)
275
307
$( $tail) *
276
308
}
277
309
} ;
0 commit comments