Skip to content

Commit

Permalink
fix: emit original token stream when there are syntax errors in `#[co…
Browse files Browse the repository at this point in the history
…mponent]` or `#[island]` function signature (closes #2133)
  • Loading branch information
gbj committed Dec 25, 2023
1 parent 34fb39c commit e3ff8fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions leptos_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ pub fn component(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
};

let mut dummy = syn::parse::<DummyModel>(s.clone());
let parse_result = syn::parse::<component::Model>(s);
let parse_result = syn::parse::<component::Model>(s.clone());

if let (Ok(ref mut unexpanded), Ok(model)) = (&mut dummy, parse_result) {
let expanded = model.is_transparent(is_transparent).into_token_stream();
Expand All @@ -623,7 +623,7 @@ pub fn component(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
#dummy
}
} else {
quote! {}
s.into()
}
.into()
}
Expand Down Expand Up @@ -703,7 +703,7 @@ pub fn component(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
#[proc_macro_attribute]
pub fn island(_args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
let mut dummy = syn::parse::<DummyModel>(s.clone());
let parse_result = syn::parse::<component::Model>(s);
let parse_result = syn::parse::<component::Model>(s.clone());

if let (Ok(ref mut unexpanded), Ok(model)) = (&mut dummy, parse_result) {
let expanded = model.is_island().into_token_stream();
Expand All @@ -728,7 +728,7 @@ pub fn island(_args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
#dummy
}
} else {
quote! {}
s.into()
}
.into()
}
Expand Down

0 comments on commit e3ff8fd

Please sign in to comment.