diff --git a/leptos_macro/src/lib.rs b/leptos_macro/src/lib.rs index 6ab9caedf3..91f2b1b387 100644 --- a/leptos_macro/src/lib.rs +++ b/leptos_macro/src/lib.rs @@ -597,10 +597,17 @@ pub fn component(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream { false }; - parse_macro_input!(s as component::Model) - .is_transparent(is_transparent) - .into_token_stream() - .into() + let parse_result = syn::parse::(s.clone()); + + match parse_result { + Ok(model) => model + .is_transparent(is_transparent) + .into_token_stream() + .into(), + // Returning the original input stream in the case of a parsing + // error helps IDEs and rust-analyzer with auto-completion. + Err(_) => s, + } } /// Defines a component as an interactive island when you are using the diff --git a/leptos_macro/src/server.rs b/leptos_macro/src/server.rs index 62448f6da0..7c2fcfc172 100644 --- a/leptos_macro/src/server.rs +++ b/leptos_macro/src/server.rs @@ -11,11 +11,12 @@ pub fn server_impl( args: proc_macro::TokenStream, s: TokenStream, ) -> TokenStream { - let function: syn::ItemFn = - match syn::parse(s).map_err(|e| e.to_compile_error()) { - Ok(f) => f, - Err(e) => return e.into(), - }; + let function: syn::ItemFn = match syn::parse(s.clone()) { + Ok(f) => f, + // Returning the original input stream in the case of a parsing + // error helps IDEs and rust-analyzer with auto-completion. + Err(_) => return s, + }; let ItemFn { attrs, vis,