From 960637e125ffeaccdec43a2be0a1c08dad00a9cb Mon Sep 17 00:00:00 2001 From: Juha Kukkonen Date: Wed, 4 May 2022 00:43:07 +0300 Subject: [PATCH] Fix unused parameter warning Fix unused parameter warning if no actix_extras nor rocket_extras is present in active features. --- utoipa-gen/src/path.rs | 1 + utoipa-gen/src/path/parameter.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/utoipa-gen/src/path.rs b/utoipa-gen/src/path.rs index 9e72655d..5c02465e 100644 --- a/utoipa-gen/src/path.rs +++ b/utoipa-gen/src/path.rs @@ -516,6 +516,7 @@ impl ToTokens for Operation<'_> { if let Some(parameters) = self.parameters { parameters.iter().for_each(|parameter| match parameter { Parameter::Value(_) => tokens.extend(quote! { .parameter(#parameter) }), + #[cfg(any(feature = "actix_extras", feature = "rocket_extras"))] Parameter::TokenStream(_) => tokens.extend(quote! { .parameters(Some(#parameter))}), }); } diff --git a/utoipa-gen/src/path/parameter.rs b/utoipa-gen/src/path/parameter.rs index 73bb6078..ee13745a 100644 --- a/utoipa-gen/src/path/parameter.rs +++ b/utoipa-gen/src/path/parameter.rs @@ -27,6 +27,7 @@ use super::property::Property; #[cfg_attr(feature = "debug", derive(Debug))] pub enum Parameter<'a> { Value(ParameterValue<'a>), + #[cfg(any(feature = "actix_extras", feature = "rocket_extras"))] TokenStream(TokenStream), } @@ -194,6 +195,7 @@ impl ToTokens for Parameter<'_> { match self { Parameter::Value(parameter) => handle_single_parameter(parameter), + #[cfg(any(feature = "actix_extras", feature = "rocket_extras"))] Parameter::TokenStream(stream) => { tokens.extend(quote! { #stream }); }