From 3f34d9bb23a180abd083b059d7d796994442682c Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Tue, 16 Jan 2024 15:31:29 -0500 Subject: [PATCH] fix: doc comments breaking server functions (closes #2190) (#2191) --- server_fn_macro/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server_fn_macro/src/lib.rs b/server_fn_macro/src/lib.rs index 949ff2a0cb..18f8a36d29 100644 --- a/server_fn_macro/src/lib.rs +++ b/server_fn_macro/src/lib.rs @@ -351,6 +351,7 @@ pub fn server_macro_impl( } struct ServerFnName { + _attrs: Vec, struct_name: Ident, _comma: Option, prefix: Option, @@ -362,6 +363,7 @@ struct ServerFnName { impl Parse for ServerFnName { fn parse(input: ParseStream) -> syn::Result { + let _attrs: Vec = input.call(Attribute::parse_outer)?; let struct_name = input.parse()?; let _comma = input.parse()?; let prefix = input.parse()?; @@ -382,6 +384,7 @@ impl Parse for ServerFnName { let fn_path = input.parse()?; Ok(Self { + _attrs, struct_name, _comma, prefix, @@ -412,7 +415,7 @@ struct ServerFnBody { /// The custom rusty variant of parsing rsx! impl Parse for ServerFnBody { fn parse(input: ParseStream) -> Result { - let attrs: Vec = input.call(Attribute::parse_outer)?; + let mut attrs: Vec = input.call(Attribute::parse_outer)?; let vis: Visibility = input.parse()?; let async_token = input.parse()?; @@ -452,6 +455,12 @@ impl Parse for ServerFnBody { Some((value.unwrap_or_default(), attr.path.span())) }) .collect(); + attrs.retain(|attr| { + let Meta::NameValue(attr) = &attr.meta else { + return true; + }; + !attr.path.is_ident("doc") + }); Ok(Self { vis,