From 74dab985aae9d647108516086300cff78b3e3924 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 27 Oct 2022 19:25:29 +0200 Subject: [PATCH] api: Use metadata macro from ruma_api! --- crates/ruma-common/src/api.rs | 3 ++- crates/ruma-macros/src/api.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ruma-common/src/api.rs b/crates/ruma-common/src/api.rs index 6da8e033..c3dbbcf6 100644 --- a/crates/ruma-common/src/api.rs +++ b/crates/ruma-common/src/api.rs @@ -480,7 +480,8 @@ macro_rules! metadata { }; // Simple literal case: used for description, name, rate_limited - ( @field $_field:ident: $rhs:literal ) => { $rhs }; + // Also used by ruma_api! while it still exists, for the history field + ( @field $_field:ident: $rhs:expr ) => { $rhs }; ( @history_impl [ $($unstable_path:literal),* ] diff --git a/crates/ruma-macros/src/api.rs b/crates/ruma-macros/src/api.rs index b0f81fa8..2c478291 100644 --- a/crates/ruma-macros/src/api.rs +++ b/crates/ruma-macros/src/api.rs @@ -59,7 +59,6 @@ impl Api { let maybe_path_error = self.check_paths().err().map(syn::Error::into_compile_error); let ruma_common = import_ruma_common(); - let http = quote! { #ruma_common::exports::http }; let metadata = &self.metadata; let description = &metadata.description; @@ -83,14 +82,17 @@ impl Api { #maybe_feature_error #maybe_path_error + // For some reason inlining the expression causes issues with macro parsing + const _RUMA_API_VERSION_HISTORY: #ruma_common::api::VersionHistory = #history; + #[doc = #metadata_doc] - pub const METADATA: #ruma_common::api::Metadata = #ruma_common::api::Metadata { + pub const METADATA: #ruma_common::api::Metadata = #ruma_common::metadata! { description: #description, - method: #http::Method::#method, + method: #method, name: #name, rate_limited: #rate_limited, - authentication: #ruma_common::api::AuthScheme::#authentication, - history: #history, + authentication: #authentication, + history: _RUMA_API_VERSION_HISTORY, }; #request