@@ -1119,7 +1119,8 @@ impl CodeGenerator for Type {
11191119 attrs. extend (
11201120 parse_tokens ( inner_attrs)
11211121 . into_iter ( )
1122- . map ( |attr| parse_quote ! { #attr } )
1122+ . filter ( |t| !t. is_empty ( ) )
1123+ . map ( |t| parse_quote ! { #t} )
11231124 . filter_map ( |attr : Attribute | {
11241125 if attr. path ( ) . is_ident ( "cfg" ) ||
11251126 attr. path ( ) . is_ident ( "link" )
@@ -2663,6 +2664,17 @@ impl CodeGenerator for CompInfo {
26632664 } ,
26642665 ) ;
26652666
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+
26662678 let mut tokens = if is_rust_union {
26672679 quote ! {
26682680 #( #attrs ) *
@@ -2869,14 +2881,15 @@ impl CodeGenerator for CompInfo {
28692881
28702882 if needs_clone_impl {
28712883 result. push ( quote ! {
2872- #( #attrs ) *
2884+ #( #cfg_attrs ) *
28732885 impl #impl_generics_labels Clone for #ty_for_impl {
28742886 fn clone( & self ) -> Self { * self }
28752887 }
28762888 } ) ;
28772889 }
28782890
28792891 if needs_flexarray_impl {
2892+ // TODO: Potentially add cfg_attrs
28802893 result. push ( self . generate_flexarray (
28812894 ctx,
28822895 & canonical_ident,
@@ -2910,7 +2923,7 @@ impl CodeGenerator for CompInfo {
29102923 // non-zero padding bytes, especially when forwards/backwards compatibility is
29112924 // involved.
29122925 result. push ( quote ! {
2913- #( #attrs ) *
2926+ #( #cfg_attrs ) *
29142927 impl #impl_generics_labels Default for #ty_for_impl {
29152928 fn default ( ) -> Self {
29162929 #body
@@ -2930,7 +2943,7 @@ impl CodeGenerator for CompInfo {
29302943 let prefix = ctx. trait_prefix ( ) ;
29312944
29322945 result. push ( quote ! {
2933- #( #attrs ) *
2946+ #( #cfg_attrs ) *
29342947 impl #impl_generics_labels :: #prefix:: fmt:: Debug for #ty_for_impl {
29352948 #impl_
29362949 }
@@ -2955,7 +2968,7 @@ impl CodeGenerator for CompInfo {
29552968
29562969 let prefix = ctx. trait_prefix ( ) ;
29572970 result. push ( quote ! {
2958- #( #attrs ) *
2971+ #( #cfg_attrs ) *
29592972 impl #impl_generics_labels :: #prefix:: cmp:: PartialEq for #ty_for_impl #partialeq_bounds {
29602973 #impl_
29612974 }
@@ -2965,7 +2978,7 @@ impl CodeGenerator for CompInfo {
29652978
29662979 if !methods. is_empty ( ) {
29672980 result. push ( quote ! {
2968- #( #attrs ) *
2981+ #( #cfg_attrs ) *
29692982 impl #impl_generics_labels #ty_for_impl {
29702983 #( #methods ) *
29712984 }
0 commit comments