131
131
//! // the `rustup_dist::ErrorKind`, with conversions from
132
132
//! // `rustup_dist::Error`.
133
133
//! //
134
+ //! // Optionally, some attributes can be added to a variant.
135
+ //! //
134
136
//! // This section can be empty.
135
137
//! links {
136
138
//! rustup_dist::Error, rustup_dist::ErrorKind, Dist;
137
- //! rustup_utils::Error, rustup_utils::ErrorKind, Utils;
139
+ //! rustup_utils::Error, rustup_utils::ErrorKind, Utils, #[cfg(unix)] ;
138
140
//! }
139
141
//!
140
142
//! // Automatic conversions between this error chain and other
143
145
//! // `ErrorKind::Temp` variant. The description and cause will
144
146
//! // forward to the description and cause of the original error.
145
147
//! //
148
+ //! // Optionally, some attributes can be added to a variant.
149
+ //! //
146
150
//! // This section can be empty.
147
151
//! foreign_links {
148
152
//! temp::Error, Temp;
153
+ //! io::Error, Io, #[cfg(unix)];
149
154
//! }
150
155
//!
151
156
//! // Define additional `ErrorKind` variants. The syntax here is
@@ -321,11 +326,11 @@ macro_rules! error_chain {
321
326
}
322
327
323
328
links {
324
- $( $link_error_path: path, $link_kind_path: path, $link_variant: ident; ) *
329
+ $( $link_error_path: path, $link_kind_path: path, $link_variant: ident $ ( , # [ $meta_links : meta ] ) * ; ) *
325
330
}
326
331
327
332
foreign_links {
328
- $( $foreign_link_error_path: path, $foreign_link_variant: ident; ) *
333
+ $( $foreign_link_error_path: path, $foreign_link_variant: ident $ ( , # [ $meta_foreign_links : meta ] ) * ; ) *
329
334
}
330
335
331
336
errors {
@@ -373,6 +378,7 @@ macro_rules! error_chain {
373
378
None => {
374
379
match self . 0 {
375
380
$(
381
+ $( #[ $meta_foreign_links] ) *
376
382
$error_kind_name:: $foreign_link_variant( ref foreign_err) => {
377
383
foreign_err. cause( )
378
384
}
@@ -391,6 +397,7 @@ macro_rules! error_chain {
391
397
}
392
398
393
399
$(
400
+ $( #[ $meta_links] ) *
394
401
impl From <$link_error_path> for $error_name {
395
402
fn from( e: $link_error_path) -> Self {
396
403
$error_name( $error_kind_name:: $link_variant( e. 0 ) , e. 1 )
@@ -399,6 +406,7 @@ macro_rules! error_chain {
399
406
) *
400
407
401
408
$(
409
+ $( #[ $meta_foreign_links] ) *
402
410
impl From <$foreign_link_error_path> for $error_name {
403
411
fn from( e: $foreign_link_error_path) -> Self {
404
412
$error_name(
@@ -443,13 +451,15 @@ macro_rules! error_chain {
443
451
}
444
452
445
453
$(
454
+ $( #[ $meta_links] ) *
446
455
$link_variant( e: $link_kind_path) {
447
456
description( e. description( ) )
448
457
display( "{}" , e)
449
458
}
450
459
) *
451
460
452
461
$(
462
+ $( #[ $meta_foreign_links] ) *
453
463
$foreign_link_variant( err: $foreign_link_error_path) {
454
464
description( :: std:: error:: Error :: description( err) )
455
465
display( "{}" , err)
@@ -461,6 +471,7 @@ macro_rules! error_chain {
461
471
}
462
472
463
473
$(
474
+ $( #[ $meta_links] ) *
464
475
impl From <$link_kind_path> for $error_kind_name {
465
476
fn from( e: $link_kind_path) -> Self {
466
477
$error_kind_name:: $link_variant( e)
@@ -559,11 +570,11 @@ macro_rules! error_chain {
559
570
}
560
571
561
572
$( links {
562
- $( $link_error_path : path , $link_kind_path : path , $link_variant : ident ; ) *
573
+ $( $link_chunks : tt ) *
563
574
} ) *
564
575
565
576
$( foreign_links {
566
- $( $foreign_link_error_path : path , $foreign_link_variant : ident ; ) *
577
+ $( $foreign_link_chunks : tt ) *
567
578
} ) *
568
579
569
580
$( errors {
@@ -576,11 +587,11 @@ macro_rules! error_chain {
576
587
}
577
588
578
589
links {
579
- $( $( $link_error_path , $link_kind_path , $link_variant ; ) * ) *
590
+ $( $( $link_chunks ) * ) *
580
591
}
581
592
582
593
foreign_links {
583
- $( $( $foreign_link_error_path , $foreign_link_variant ; ) * ) *
594
+ $( $( $foreign_link_chunks ) * ) *
584
595
}
585
596
586
597
errors {
@@ -593,11 +604,11 @@ macro_rules! error_chain {
593
604
types { }
594
605
595
606
$( links {
596
- $( $link_error_path : path , $link_kind_path : path , $link_variant : ident ; ) *
607
+ $( $link_chunks : tt ) *
597
608
} ) *
598
609
599
610
$( foreign_links {
600
- $( $foreign_link_error_path : path , $foreign_link_variant : ident ; ) *
611
+ $( $foreign_link_chunks : tt ) *
601
612
} ) *
602
613
603
614
$( errors {
@@ -610,11 +621,11 @@ macro_rules! error_chain {
610
621
}
611
622
612
623
links {
613
- $( $( $link_error_path , $link_kind_path , $link_variant ; ) * ) *
624
+ $( $( $link_chunks ) * ) *
614
625
}
615
626
616
627
foreign_links {
617
- $( $( $foreign_link_error_path , $foreign_link_variant ; ) * ) *
628
+ $( $( $foreign_link_chunks ) * ) *
618
629
}
619
630
620
631
errors {
@@ -625,11 +636,11 @@ macro_rules! error_chain {
625
636
// Case 3: types section not present
626
637
(
627
638
$( links {
628
- $( $link_error_path : path , $link_kind_path : path , $link_variant : ident ; ) *
639
+ $( $link_chunks : tt ) *
629
640
} ) *
630
641
631
642
$( foreign_links {
632
- $( $foreign_link_error_path : path , $foreign_link_variant : ident ; ) *
643
+ $( $foreign_link_chunks : tt ) *
633
644
} ) *
634
645
635
646
$( errors {
@@ -640,11 +651,11 @@ macro_rules! error_chain {
640
651
types { }
641
652
642
653
links {
643
- $( $( $link_error_path , $link_kind_path , $link_variant ; ) * ) *
654
+ $( $( $link_chunks ) * ) *
644
655
}
645
656
646
657
foreign_links {
647
- $( $( $foreign_link_error_path , $foreign_link_variant ; ) * ) *
658
+ $( $( $foreign_link_chunks ) * ) *
648
659
}
649
660
650
661
errors {
0 commit comments