Skip to content

Commit

Permalink
fix: allow non static lifetimes in component macro (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwrf authored Feb 11, 2025
1 parent 03f9c6c commit b17a4c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions leptos_macro/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ impl ToTokens for Model {
let (impl_generics, generics, where_clause) =
body.sig.generics.split_for_impl();

let lifetimes = body.sig.generics.lifetimes();

let props_name = format_ident!("{name}Props");
let props_builder_name = format_ident!("{name}PropsBuilder");
let props_serialized_name = format_ident!("{name}PropsSerialized");
Expand Down Expand Up @@ -570,7 +568,7 @@ impl ToTokens for Model {
#tracing_instrument_attr
#vis fn #name #impl_generics (
#props_arg
) #ret #(+ #lifetimes)*
) #ret
#where_clause
{
#body
Expand Down
15 changes: 15 additions & 0 deletions leptos_macro/tests/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,18 @@ fn component_nostrip() {
/>
};
}

#[component]
fn WithLifetime<'a>(data: &'a str) -> impl IntoView {
_ = data;
"static lifetime"
}

#[test]
fn returns_static_lifetime() {
#[allow(unused)]
fn can_return_impl_intoview_from_body() -> impl IntoView {
let val = String::from("non_static_lifetime");
WithLifetime(WithLifetimeProps::builder().data(&val).build())
}
}

0 comments on commit b17a4c9

Please sign in to comment.