From d220ab0fbe83ec08f024df350eec5fc7482d1a00 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Dec 2020 16:40:57 +0100 Subject: [PATCH] Outgoing derive: Copy `cfg` and `cfg_attr` attributes to Incoming type --- ruma-serde-macros/src/outgoing.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ruma-serde-macros/src/outgoing.rs b/ruma-serde-macros/src/outgoing.rs index 024f739d..aaf637ee 100644 --- a/ruma-serde-macros/src/outgoing.rs +++ b/ruma-serde-macros/src/outgoing.rs @@ -147,10 +147,13 @@ pub fn expand_derive_outgoing(input: DeriveInput) -> syn::Result { } } -/// 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 {