@@ -1119,7 +1119,8 @@ impl CodeGenerator for Type {
1119
1119
attrs. extend (
1120
1120
parse_tokens ( inner_attrs)
1121
1121
. into_iter ( )
1122
- . map ( |attr| parse_quote ! { #attr } )
1122
+ . filter ( |t| !t. is_empty ( ) )
1123
+ . map ( |t| parse_quote ! { #t} )
1123
1124
. filter_map ( |attr : Attribute | {
1124
1125
if attr. path ( ) . is_ident ( "cfg" ) ||
1125
1126
attr. path ( ) . is_ident ( "link" )
@@ -2663,6 +2664,17 @@ impl CodeGenerator for CompInfo {
2663
2664
} ,
2664
2665
) ;
2665
2666
2667
+ // TODO: Make `cfg_attrs`
2668
+ let cfg_attrs = attrs
2669
+ . iter ( )
2670
+ . filter ( |t| !t. is_empty ( ) )
2671
+ . map ( |t| parse_quote ! { #t} )
2672
+ . filter ( |attr : & Attribute | {
2673
+ let path = attr. path ( ) ;
2674
+ path. is_ident ( "cfg" ) || path. is_ident ( "link" )
2675
+ } )
2676
+ . collect :: < Vec < _ > > ( ) ;
2677
+
2666
2678
let mut tokens = if is_rust_union {
2667
2679
quote ! {
2668
2680
#( #attrs ) *
@@ -2869,14 +2881,15 @@ impl CodeGenerator for CompInfo {
2869
2881
2870
2882
if needs_clone_impl {
2871
2883
result. push ( quote ! {
2872
- #( #attrs ) *
2884
+ #( #cfg_attrs ) *
2873
2885
impl #impl_generics_labels Clone for #ty_for_impl {
2874
2886
fn clone( & self ) -> Self { * self }
2875
2887
}
2876
2888
} ) ;
2877
2889
}
2878
2890
2879
2891
if needs_flexarray_impl {
2892
+ // TODO: Potentially add cfg_attrs
2880
2893
result. push ( self . generate_flexarray (
2881
2894
ctx,
2882
2895
& canonical_ident,
@@ -2910,7 +2923,7 @@ impl CodeGenerator for CompInfo {
2910
2923
// non-zero padding bytes, especially when forwards/backwards compatibility is
2911
2924
// involved.
2912
2925
result. push ( quote ! {
2913
- #( #attrs ) *
2926
+ #( #cfg_attrs ) *
2914
2927
impl #impl_generics_labels Default for #ty_for_impl {
2915
2928
fn default ( ) -> Self {
2916
2929
#body
@@ -2930,7 +2943,7 @@ impl CodeGenerator for CompInfo {
2930
2943
let prefix = ctx. trait_prefix ( ) ;
2931
2944
2932
2945
result. push ( quote ! {
2933
- #( #attrs ) *
2946
+ #( #cfg_attrs ) *
2934
2947
impl #impl_generics_labels :: #prefix:: fmt:: Debug for #ty_for_impl {
2935
2948
#impl_
2936
2949
}
@@ -2955,7 +2968,7 @@ impl CodeGenerator for CompInfo {
2955
2968
2956
2969
let prefix = ctx. trait_prefix ( ) ;
2957
2970
result. push ( quote ! {
2958
- #( #attrs ) *
2971
+ #( #cfg_attrs ) *
2959
2972
impl #impl_generics_labels :: #prefix:: cmp:: PartialEq for #ty_for_impl #partialeq_bounds {
2960
2973
#impl_
2961
2974
}
@@ -2965,7 +2978,7 @@ impl CodeGenerator for CompInfo {
2965
2978
2966
2979
if !methods. is_empty ( ) {
2967
2980
result. push ( quote ! {
2968
- #( #attrs ) *
2981
+ #( #cfg_attrs ) *
2969
2982
impl #impl_generics_labels #ty_for_impl {
2970
2983
#( #methods ) *
2971
2984
}
0 commit comments