macros: Generate certain structs only with client or server feature enabled

If neither the client, nor the server feature is enabled the fields are
unused and therefore trigger the dead_code lint.
This commit is contained in:
Marcel Hellwig 2022-06-22 14:15:37 +02:00 committed by GitHub
parent 195091c051
commit 92f862e279
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -198,6 +198,7 @@ impl Request {
quote! { quote! {
/// Data in the request body. /// Data in the request body.
#[cfg(any(feature = "client", feature = "server"))]
#[derive(Debug, #ruma_macros::_FakeDeriveRumaApi, #ruma_macros::_FakeDeriveSerde)] #[derive(Debug, #ruma_macros::_FakeDeriveRumaApi, #ruma_macros::_FakeDeriveSerde)]
#[cfg_attr(feature = "client", derive(#serde::Serialize))] #[cfg_attr(feature = "client", derive(#serde::Serialize))]
#[cfg_attr( #[cfg_attr(
@ -225,6 +226,7 @@ impl Request {
quote! { quote! {
/// Data in the request's query string. /// Data in the request's query string.
#[cfg(any(feature = "client", feature = "server"))]
#[derive(Debug, #ruma_macros::_FakeDeriveRumaApi, #ruma_macros::_FakeDeriveSerde)] #[derive(Debug, #ruma_macros::_FakeDeriveRumaApi, #ruma_macros::_FakeDeriveSerde)]
#[cfg_attr(feature = "client", derive(#serde::Serialize))] #[cfg_attr(feature = "client", derive(#serde::Serialize))]
#[cfg_attr( #[cfg_attr(

View File

@ -100,6 +100,7 @@ impl Response {
quote! { quote! {
/// Data in the response body. /// Data in the response body.
#[cfg(any(feature = "client", feature = "server"))]
#[derive(Debug, #ruma_macros::_FakeDeriveRumaApi, #ruma_macros::_FakeDeriveSerde)] #[derive(Debug, #ruma_macros::_FakeDeriveRumaApi, #ruma_macros::_FakeDeriveSerde)]
#serde_derives #serde_derives
#serde_attr #serde_attr