@@ -1073,20 +1073,18 @@ impl CodeGenerator for Type {
1073
1073
kind : AttributeItemKind :: Struct ,
1074
1074
} )
1075
1075
} ) ;
1076
- attributes. extend (
1077
- custom_attributes
1078
- . iter ( )
1079
- . map ( |s| s. parse ( ) . unwrap ( ) ) ,
1080
- ) ;
1076
+
1077
+ // HACK: Smuggle annotations back into the system for type aliases
1078
+ item. annotations ( )
1079
+ . attributes ( )
1080
+ . extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
1081
+
1081
1082
attributes. extend (
1082
1083
item. annotations ( ) . attributes ( )
1083
1084
. iter ( )
1084
1085
. map ( |s| s. parse ( ) . unwrap ( ) ) ,
1085
1086
) ;
1086
-
1087
1087
1088
-
1089
-
1090
1088
quote ! {
1091
1089
#( #attributes ) *
1092
1090
pub struct #rust_name
@@ -2530,13 +2528,6 @@ impl CodeGenerator for CompInfo {
2530
2528
attributes. push ( attributes:: derives ( & derives) ) ;
2531
2529
}
2532
2530
2533
- attributes. extend (
2534
- item. annotations ( )
2535
- . attributes ( )
2536
- . iter ( )
2537
- . map ( |s| s. parse ( ) . unwrap ( ) ) ,
2538
- ) ;
2539
-
2540
2531
let custom_attributes = ctx. options ( ) . all_callbacks ( |cb| {
2541
2532
cb. add_attributes ( & AttributeInfo {
2542
2533
name : & canonical_name,
@@ -2547,8 +2538,18 @@ impl CodeGenerator for CompInfo {
2547
2538
} ,
2548
2539
} )
2549
2540
} ) ;
2550
- attributes. extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
2541
+ // HACK: Smuggle annotations back into the system for type aliases
2542
+ item. annotations ( )
2543
+ . attributes ( )
2544
+ . extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
2551
2545
2546
+ attributes. extend (
2547
+ item. annotations ( )
2548
+ . attributes ( )
2549
+ . iter ( )
2550
+ . map ( |s| s. parse ( ) . unwrap ( ) ) ,
2551
+ ) ;
2552
+
2552
2553
if item. must_use ( ctx) {
2553
2554
attributes. push ( attributes:: must_use ( ) ) ;
2554
2555
}
@@ -3155,13 +3156,6 @@ impl Method {
3155
3156
let block = ctx. wrap_unsafe_ops ( quote ! ( #( #stmts ) ; * ) ) ;
3156
3157
3157
3158
let mut attrs = vec ! [ attributes:: inline( ) ] ;
3158
- attrs. extend (
3159
- function_item
3160
- . annotations ( )
3161
- . attributes ( )
3162
- . iter ( )
3163
- . map ( |s| s. parse ( ) . unwrap ( ) ) ,
3164
- ) ;
3165
3159
3166
3160
let custom_attributes = ctx. options ( ) . all_callbacks ( |cb| {
3167
3161
cb. add_attributes ( & AttributeInfo {
@@ -3171,7 +3165,19 @@ impl Method {
3171
3165
) ) ,
3172
3166
} )
3173
3167
} ) ;
3174
- attrs. extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
3168
+
3169
+ // HACK: Smuggle annotations back into the system for type aliases
3170
+ function_item. annotations ( )
3171
+ . attributes ( )
3172
+ . extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
3173
+
3174
+ attrs. extend (
3175
+ function_item
3176
+ . annotations ( )
3177
+ . attributes ( )
3178
+ . iter ( )
3179
+ . map ( |s| s. parse ( ) . unwrap ( ) ) ,
3180
+ ) ;
3175
3181
3176
3182
if signature. must_use ( ) {
3177
3183
attrs. push ( attributes:: must_use ( ) ) ;
@@ -3741,12 +3747,6 @@ impl CodeGenerator for Enum {
3741
3747
// In most cases this will be a no-op, since custom_derives will be empty.
3742
3748
derives. extend ( custom_derives. iter ( ) . map ( |s| s. as_str ( ) ) ) ;
3743
3749
3744
- attrs. extend (
3745
- item. annotations ( )
3746
- . attributes ( )
3747
- . iter ( )
3748
- . map ( |s| s. parse ( ) . unwrap ( ) ) ,
3749
- ) ;
3750
3750
3751
3751
// The custom attribute callback may return a list of attributes;
3752
3752
// add them to the end of the list.
@@ -3756,8 +3756,18 @@ impl CodeGenerator for Enum {
3756
3756
kind : AttributeItemKind :: Enum ,
3757
3757
} )
3758
3758
} ) ;
3759
- attrs. extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
3760
3759
3760
+ // HACK: Smuggle annotations back into the system for type aliases
3761
+ item. annotations ( )
3762
+ . attributes ( )
3763
+ . extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
3764
+
3765
+ attrs. extend (
3766
+ item. annotations ( )
3767
+ . attributes ( )
3768
+ . iter ( )
3769
+ . map ( |s| s. parse ( ) . unwrap ( ) ) ,
3770
+ ) ;
3761
3771
attrs. push ( attributes:: derives ( & derives) ) ;
3762
3772
}
3763
3773
@@ -4617,20 +4627,25 @@ impl CodeGenerator for Function {
4617
4627
}
4618
4628
4619
4629
let mut attributes = vec ! [ ] ;
4620
- attributes. extend (
4621
- item. annotations ( )
4622
- . attributes ( )
4623
- . iter ( )
4624
- . map ( |s| s. parse ( ) . unwrap ( ) ) ,
4625
- ) ;
4626
4630
4627
4631
let custom_attributes = ctx. options ( ) . all_callbacks ( |cb| {
4628
4632
cb. add_attributes ( & AttributeInfo {
4629
4633
name : & canonical_name,
4630
4634
kind : AttributeItemKind :: Function ( self . kind ( ) ) ,
4631
4635
} )
4632
4636
} ) ;
4633
- attributes. extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
4637
+
4638
+ // HACK: Smuggle annotations back into the system for type aliases
4639
+ item. annotations ( )
4640
+ . attributes ( )
4641
+ . extend ( custom_attributes. iter ( ) . map ( |s| s. parse ( ) . unwrap ( ) ) ) ;
4642
+
4643
+ attributes. extend (
4644
+ item. annotations ( )
4645
+ . attributes ( )
4646
+ . iter ( )
4647
+ . map ( |s| s. parse ( ) . unwrap ( ) ) ,
4648
+ ) ;
4634
4649
4635
4650
if true {
4636
4651
let must_use = signature. must_use ( ) || {
0 commit comments