Outgoing derive: Copy cfg and cfg_attr attributes to Incoming type

This commit is contained in:
Jonas Platte 2020-12-10 16:40:57 +01:00
parent cf77181072
commit d220ab0fbe
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -147,10 +147,13 @@ pub fn expand_derive_outgoing(input: DeriveInput) -> syn::Result<TokenStream> {
}
}
/// Keep any `serde` or `non_exhaustive` attributes found and
/// pass them to the Incoming variant.
/// Keep any `cfg`, `cfg_attr`, `serde` or `non_exhaustive` attributes found and pass them to the
/// Incoming variant.
fn filter_input_attrs(attr: &Attribute) -> bool {
attr.path.is_ident("serde") || attr.path.is_ident("non_exhaustive")
attr.path.is_ident("cfg")
|| attr.path.is_ident("cfg_attr")
|| attr.path.is_ident("serde")
|| attr.path.is_ident("non_exhaustive")
}
fn impl_outgoing_with_incoming_self(input: &DeriveInput, ruma_serde: &TokenStream) -> TokenStream {