From 1dcc5838f73451d722880c47903ef3f7cfdd2b98 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Thu, 30 Jan 2025 21:42:39 -0500 Subject: [PATCH 1/6] `v0.7.5` --- Cargo.lock | 48 ++++++++++++++++---------------- Cargo.toml | 32 ++++++++++----------- either_of/Cargo.toml | 4 +-- leptos_macro/Cargo.toml | 2 +- meta/Cargo.toml | 2 +- reactive_graph/Cargo.toml | 2 +- reactive_stores/Cargo.toml | 2 +- reactive_stores_macro/Cargo.toml | 2 +- router/Cargo.toml | 2 +- router_macro/Cargo.toml | 2 +- tachys/Cargo.toml | 3 +- 11 files changed, 50 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60472dfb13..bd5b32e530 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -333,9 +333,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", @@ -879,7 +879,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "either_of" -version = "0.1.4" +version = "0.1.5" dependencies = [ "paste", "pin-project-lite", @@ -1718,7 +1718,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "leptos" -version = "0.7.4" +version = "0.7.5" dependencies = [ "any_spawner", "base64", @@ -1769,7 +1769,7 @@ dependencies = [ [[package]] name = "leptos_actix" -version = "0.7.4" +version = "0.7.5" dependencies = [ "actix-files", "actix-http", @@ -1794,7 +1794,7 @@ dependencies = [ [[package]] name = "leptos_axum" -version = "0.7.4" +version = "0.7.5" dependencies = [ "any_spawner", "axum", @@ -1817,7 +1817,7 @@ dependencies = [ [[package]] name = "leptos_config" -version = "0.7.4" +version = "0.7.5" dependencies = [ "config", "regex", @@ -1831,7 +1831,7 @@ dependencies = [ [[package]] name = "leptos_dom" -version = "0.7.4" +version = "0.7.5" dependencies = [ "js-sys", "leptos", @@ -1848,7 +1848,7 @@ dependencies = [ [[package]] name = "leptos_hot_reload" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "camino", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "leptos_integration_utils" -version = "0.7.4" +version = "0.7.5" dependencies = [ "futures", "hydration_context", @@ -1877,7 +1877,7 @@ dependencies = [ [[package]] name = "leptos_macro" -version = "0.7.4" +version = "0.7.5" dependencies = [ "attribute-derive", "cfg-if", @@ -1896,7 +1896,7 @@ dependencies = [ "rstml", "serde", "server_fn", - "server_fn_macro 0.7.4", + "server_fn_macro 0.7.5", "syn 2.0.90", "tracing", "trybuild", @@ -1906,7 +1906,7 @@ dependencies = [ [[package]] name = "leptos_meta" -version = "0.7.4" +version = "0.7.5" dependencies = [ "futures", "indexmap", @@ -1921,7 +1921,7 @@ dependencies = [ [[package]] name = "leptos_router" -version = "0.7.4" +version = "0.7.5" dependencies = [ "any_spawner", "either_of", @@ -1945,7 +1945,7 @@ dependencies = [ [[package]] name = "leptos_router_macro" -version = "0.7.4" +version = "0.7.5" dependencies = [ "leptos_macro", "leptos_router", @@ -1957,7 +1957,7 @@ dependencies = [ [[package]] name = "leptos_server" -version = "0.7.4" +version = "0.7.5" dependencies = [ "any_spawner", "base64", @@ -2659,7 +2659,7 @@ dependencies = [ [[package]] name = "reactive_graph" -version = "0.1.4" +version = "0.1.5" dependencies = [ "any_spawner", "async-lock", @@ -2681,7 +2681,7 @@ dependencies = [ [[package]] name = "reactive_stores" -version = "0.1.3" +version = "0.1.5" dependencies = [ "any_spawner", "guardian", @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "reactive_stores_macro" -version = "0.1.0" +version = "0.1.5" dependencies = [ "convert_case 0.6.0", "proc-macro-error2", @@ -3155,7 +3155,7 @@ dependencies = [ [[package]] name = "server_fn" -version = "0.7.4" +version = "0.7.5" dependencies = [ "actix-web", "axum", @@ -3211,7 +3211,7 @@ dependencies = [ [[package]] name = "server_fn_macro" -version = "0.7.4" +version = "0.7.5" dependencies = [ "const_format", "convert_case 0.6.0", @@ -3223,9 +3223,9 @@ dependencies = [ [[package]] name = "server_fn_macro_default" -version = "0.7.4" +version = "0.7.5" dependencies = [ - "server_fn_macro 0.7.4", + "server_fn_macro 0.7.5", "syn 2.0.90", ] @@ -3419,7 +3419,7 @@ dependencies = [ [[package]] name = "tachys" -version = "0.1.4" +version = "0.1.5" dependencies = [ "any_spawner", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 4cee16ee7a..51ce42b271 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ members = [ exclude = ["benchmarks", "examples", "projects"] [workspace.package] -version = "0.7.4" +version = "0.7.5" edition = "2021" rust-version = "1.76" @@ -50,26 +50,26 @@ any_spawner = { path = "./any_spawner/", version = "0.2.0" } const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" } either_of = { path = "./either_of/", version = "0.1.0" } hydration_context = { path = "./hydration_context", version = "0.2.0" } -leptos = { path = "./leptos", version = "0.7.4" } -leptos_config = { path = "./leptos_config", version = "0.7.4" } -leptos_dom = { path = "./leptos_dom", version = "0.7.4" } -leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.4" } -leptos_integration_utils = { path = "./integrations/utils", version = "0.7.4" } -leptos_macro = { path = "./leptos_macro", version = "0.7.4" } -leptos_router = { path = "./router", version = "0.7.4" } -leptos_router_macro = { path = "./router_macro", version = "0.7.4" } -leptos_server = { path = "./leptos_server", version = "0.7.4" } -leptos_meta = { path = "./meta", version = "0.7.4" } +leptos = { path = "./leptos", version = "0.7.5" } +leptos_config = { path = "./leptos_config", version = "0.7.5" } +leptos_dom = { path = "./leptos_dom", version = "0.7.5" } +leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.5" } +leptos_integration_utils = { path = "./integrations/utils", version = "0.7.5" } +leptos_macro = { path = "./leptos_macro", version = "0.7.5" } +leptos_router = { path = "./router", version = "0.7.5" } +leptos_router_macro = { path = "./router_macro", version = "0.7.5" } +leptos_server = { path = "./leptos_server", version = "0.7.5" } +leptos_meta = { path = "./meta", version = "0.7.5" } next_tuple = { path = "./next_tuple", version = "0.1.0" } oco_ref = { path = "./oco", version = "0.2.0" } or_poisoned = { path = "./or_poisoned", version = "0.1.0" } -reactive_graph = { path = "./reactive_graph", version = "0.1.4" } +reactive_graph = { path = "./reactive_graph", version = "0.1.5" } reactive_stores = { path = "./reactive_stores", version = "0.1.3" } reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0" } -server_fn = { path = "./server_fn", version = "0.7.4" } -server_fn_macro = { path = "./server_fn_macro", version = "0.7.4" } -server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.4" } -tachys = { path = "./tachys", version = "0.1.4" } +server_fn = { path = "./server_fn", version = "0.7.5" } +server_fn_macro = { path = "./server_fn_macro", version = "0.7.5" } +server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.5" } +tachys = { path = "./tachys", version = "0.1.5" } [profile.release] codegen-units = 1 diff --git a/either_of/Cargo.toml b/either_of/Cargo.toml index bc120cee45..15e0d145bf 100644 --- a/either_of/Cargo.toml +++ b/either_of/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "either_of" -version = "0.1.4" +version = "0.1.5" authors = ["Greg Johnston"] license = "MIT" readme = "../README.md" @@ -15,4 +15,4 @@ paste = "1.0.15" [features] default = ["no_std"] -no_std = [] \ No newline at end of file +no_std = [] diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index 9fd20ed7ea..e3f6a43872 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leptos_macro" -version = "0.7.4" +version = "0.7.5" authors = ["Greg Johnston"] license = "MIT" repository = "https://github.com/leptos-rs/leptos" diff --git a/meta/Cargo.toml b/meta/Cargo.toml index 1f0d0f3fb5..697f02ad49 100644 --- a/meta/Cargo.toml +++ b/meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leptos_meta" -version = "0.7.4" +version = "0.7.5" authors = ["Greg Johnston"] license = "MIT" repository = "https://github.com/leptos-rs/leptos" diff --git a/reactive_graph/Cargo.toml b/reactive_graph/Cargo.toml index 53d3ebb3b5..165f999522 100644 --- a/reactive_graph/Cargo.toml +++ b/reactive_graph/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reactive_graph" -version = "0.1.4" +version = "0.1.5" authors = ["Greg Johnston"] license = "MIT" readme = "../README.md" diff --git a/reactive_stores/Cargo.toml b/reactive_stores/Cargo.toml index fb2e31a671..4455a91988 100644 --- a/reactive_stores/Cargo.toml +++ b/reactive_stores/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reactive_stores" -version = "0.1.3" +version = "0.1.5" authors = ["Greg Johnston"] license = "MIT" readme = "../README.md" diff --git a/reactive_stores_macro/Cargo.toml b/reactive_stores_macro/Cargo.toml index 5b79d5c7fd..b7a1823a13 100644 --- a/reactive_stores_macro/Cargo.toml +++ b/reactive_stores_macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reactive_stores_macro" -version = "0.1.0" +version = "0.1.5" authors = ["Greg Johnston"] license = "MIT" readme = "../README.md" diff --git a/router/Cargo.toml b/router/Cargo.toml index 0251832e2e..04e8465521 100644 --- a/router/Cargo.toml +++ b/router/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leptos_router" -version = "0.7.4" +version = "0.7.5" authors = ["Greg Johnston", "Ben Wishovich"] license = "MIT" readme = "../README.md" diff --git a/router_macro/Cargo.toml b/router_macro/Cargo.toml index df4e281bea..765324fb24 100644 --- a/router_macro/Cargo.toml +++ b/router_macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "leptos_router_macro" -version = "0.7.4" +version = "0.7.5" authors = ["Greg Johnston", "Ben Wishovich"] license = "MIT" readme = "../README.md" diff --git a/tachys/Cargo.toml b/tachys/Cargo.toml index f71678fd45..26b1f6f0f3 100644 --- a/tachys/Cargo.toml +++ b/tachys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tachys" -version = "0.1.4" +version = "0.1.5" authors = ["Greg Johnston"] license = "MIT" readme = "../README.md" @@ -204,4 +204,3 @@ unexpected_cfgs = { level = "warn", check-cfg = [ 'cfg(leptos_debuginfo)', 'cfg(erase_components)', ] } - From e3010c7f1f49875f40379bfad0fa4df3c9dfa596 Mon Sep 17 00:00:00 2001 From: Serhii Stepanchuk <96484585+sstepanchuk@users.noreply.github.com> Date: Fri, 31 Jan 2025 19:33:55 +0200 Subject: [PATCH 2/6] feat: add `file_and_error_handler_with_context` (#3526) * add file_and_error_handler_with_context like in leptos_routes_with_context func * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- integrations/axum/src/lib.rs | 89 ++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/integrations/axum/src/lib.rs b/integrations/axum/src/lib.rs index 80bc2da22b..485edd5f4b 100644 --- a/integrations/axum/src/lib.rs +++ b/integrations/axum/src/lib.rs @@ -1981,7 +1981,8 @@ where /// This is provided as a convenience, but is a fairly simple function. If you need to adapt it, /// simply reuse the source code of this function in your own application. #[cfg(feature = "default")] -pub fn file_and_error_handler( +pub fn file_and_error_handler_with_context( + additional_context: impl Fn() + 'static + Clone + Send, shell: fn(LeptosOptions) -> IV, ) -> impl Fn( Uri, @@ -1997,40 +1998,68 @@ where LeptosOptions: FromRef, { move |uri: Uri, State(state): State, req: Request| { - Box::pin(async move { - let options = LeptosOptions::from_ref(&state); - let res = get_static_file(uri, &options.site_root, req.headers()); - let res = res.await.unwrap(); - - if res.status() == StatusCode::OK { - res.into_response() - } else { - let mut res = handle_response_inner( - move || { - provide_context(state.clone()); - }, - move || shell(options), - req, - |app, chunks| { - Box::pin(async move { - let app = app - .to_html_stream_in_order() - .collect::() - .await; - let chunks = chunks(); - Box::pin(once(async move { app }).chain(chunks)) - as PinnedStream - }) - }, - ) - .await; - *res.status_mut() = StatusCode::NOT_FOUND; - res + Box::pin({ + let additional_context = additional_context.clone(); + async move { + let options = LeptosOptions::from_ref(&state); + let res = + get_static_file(uri, &options.site_root, req.headers()); + let res = res.await.unwrap(); + + if res.status() == StatusCode::OK { + res.into_response() + } else { + let mut res = handle_response_inner( + move || { + additional_context(); + provide_context(state.clone()); + }, + move || shell(options), + req, + |app, chunks| { + Box::pin(async move { + let app = app + .to_html_stream_in_order() + .collect::() + .await; + let chunks = chunks(); + Box::pin(once(async move { app }).chain(chunks)) + as PinnedStream + }) + }, + ) + .await; + *res.status_mut() = StatusCode::NOT_FOUND; + res + } } }) } } +/// A reasonable handler for serving static files (like JS/WASM/CSS) and 404 errors. +/// +/// This is provided as a convenience, but is a fairly simple function. If you need to adapt it, +/// simply reuse the source code of this function in your own application. +#[cfg(feature = "default")] +pub fn file_and_error_handler( + shell: fn(LeptosOptions) -> IV, +) -> impl Fn( + Uri, + State, + Request, +) -> Pin> + Send + 'static>> + + Clone + + Send + + 'static +where + IV: IntoView + 'static, + S: Send + Sync + Clone + 'static, + LeptosOptions: FromRef, +{ + file_and_error_handler_with_context(move || (), shell) +} + #[cfg(feature = "default")] async fn get_static_file( uri: Uri, From d9043e4f34371f14567133f8d0fc2347fbb6f949 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sat, 1 Feb 2025 09:37:38 -0500 Subject: [PATCH 3/6] feat: impl `From>` for `Field` (#3533) * feat: impl `From>` for `Field` * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- reactive_stores/src/field.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/reactive_stores/src/field.rs b/reactive_stores/src/field.rs index 644ab8ca3e..ad4fa09b09 100644 --- a/reactive_stores/src/field.rs +++ b/reactive_stores/src/field.rs @@ -82,6 +82,21 @@ where } } +impl From> for Field +where + T: 'static, + S: Storage>, +{ + #[track_caller] + fn from(value: ArcField) -> Self { + Field { + #[cfg(any(debug_assertions, leptos_debuginfo))] + defined_at: Location::caller(), + inner: ArenaItem::new_with_storage(value), + } + } +} + impl From> for Field where T: Send + Sync + 'static, From 32be3a023a5413fe17f81d9a0a76f719c1ad4e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Radi=C4=8Dek?= Date: Sat, 1 Feb 2025 15:40:43 +0100 Subject: [PATCH 4/6] feat: implement `PatchField` for `Option<_>` (#3528) --- reactive_stores/src/option.rs | 114 +++++++++++++++++++++++++++++++++- reactive_stores/src/patch.rs | 29 +++++++++ 2 files changed, 142 insertions(+), 1 deletion(-) diff --git a/reactive_stores/src/option.rs b/reactive_stores/src/option.rs index 439eceb5b8..8343c584ea 100644 --- a/reactive_stores/src/option.rs +++ b/reactive_stores/src/option.rs @@ -77,11 +77,12 @@ where #[cfg(test)] mod tests { - use crate::{self as reactive_stores, Store}; + use crate::{self as reactive_stores, Patch as _, Store}; use reactive_graph::{ effect::Effect, traits::{Get, Read, ReadUntracked, Set, Write}, }; + use reactive_stores_macro::Patch; use std::sync::{ atomic::{AtomicUsize, Ordering}, Arc, @@ -237,4 +238,115 @@ mod tests { assert_eq!(parent_count.load(Ordering::Relaxed), 3); assert_eq!(inner_count.load(Ordering::Relaxed), 3); } + + #[tokio::test] + async fn patch() { + use crate::OptionStoreExt; + + #[derive(Debug, Clone, Store, Patch)] + struct Outer { + inner: Option, + } + + #[derive(Debug, Clone, Store, Patch)] + struct Inner { + first: String, + second: String, + } + + let store = Store::new(Outer { + inner: Some(Inner { + first: "A".to_owned(), + second: "B".to_owned(), + }), + }); + + _ = any_spawner::Executor::init_tokio(); + + let parent_count = Arc::new(AtomicUsize::new(0)); + let inner_first_count = Arc::new(AtomicUsize::new(0)); + let inner_second_count = Arc::new(AtomicUsize::new(0)); + + Effect::new_sync({ + let parent_count = Arc::clone(&parent_count); + move |prev: Option<()>| { + if prev.is_none() { + println!("parent: first run"); + } else { + println!("parent: next run"); + } + + println!(" value = {:?}", store.inner().get()); + parent_count.fetch_add(1, Ordering::Relaxed); + } + }); + Effect::new_sync({ + let inner_first_count = Arc::clone(&inner_first_count); + move |prev: Option<()>| { + if prev.is_none() { + println!("inner_first: first run"); + } else { + println!("inner_first: next run"); + } + + println!( + " value = {:?}", + store.inner().map(|inner| inner.first().get()) + ); + inner_first_count.fetch_add(1, Ordering::Relaxed); + } + }); + Effect::new_sync({ + let inner_second_count = Arc::clone(&inner_second_count); + move |prev: Option<()>| { + if prev.is_none() { + println!("inner_second: first run"); + } else { + println!("inner_second: next run"); + } + + println!( + " value = {:?}", + store.inner().map(|inner| inner.second().get()) + ); + inner_second_count.fetch_add(1, Ordering::Relaxed); + } + }); + + tick().await; + assert_eq!(parent_count.load(Ordering::Relaxed), 1); + assert_eq!(inner_first_count.load(Ordering::Relaxed), 1); + assert_eq!(inner_second_count.load(Ordering::Relaxed), 1); + + store.patch(Outer { + inner: Some(Inner { + first: "A".to_string(), + second: "C".to_string(), + }), + }); + + tick().await; + assert_eq!(parent_count.load(Ordering::Relaxed), 1); + assert_eq!(inner_first_count.load(Ordering::Relaxed), 1); + assert_eq!(inner_second_count.load(Ordering::Relaxed), 2); + + store.patch(Outer { inner: None }); + + tick().await; + assert_eq!(parent_count.load(Ordering::Relaxed), 2); + assert_eq!(inner_first_count.load(Ordering::Relaxed), 2); + assert_eq!(inner_second_count.load(Ordering::Relaxed), 3); + + store.patch(Outer { + inner: Some(Inner { + first: "A".to_string(), + second: "B".to_string(), + }), + }); + + tick().await; + assert_eq!(parent_count.load(Ordering::Relaxed), 3); + assert_eq!(inner_first_count.load(Ordering::Relaxed), 3); + assert_eq!(inner_second_count.load(Ordering::Relaxed), 4); + } } diff --git a/reactive_stores/src/patch.rs b/reactive_stores/src/patch.rs index f88fa8b585..7c65467115 100644 --- a/reactive_stores/src/patch.rs +++ b/reactive_stores/src/patch.rs @@ -114,6 +114,35 @@ patch_primitives! { NonZeroUsize } +impl PatchField for Option +where + T: PatchField, +{ + fn patch_field( + &mut self, + new: Self, + path: &StorePath, + notify: &mut dyn FnMut(&StorePath), + ) { + match (self, new) { + (None, None) => {} + (old @ Some(_), None) => { + old.take(); + notify(path); + } + (old @ None, new @ Some(_)) => { + *old = new; + notify(path); + } + (Some(old), Some(new)) => { + let mut new_path = path.to_owned(); + new_path.push(0); + old.patch_field(new, &new_path, notify); + } + } + } +} + impl PatchField for Vec where T: PatchField, From 6154199850b0eb78883128684bc9f70b1009cb94 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sat, 1 Feb 2025 11:32:32 -0500 Subject: [PATCH 5/6] fix: attribute type erasure nightly (closes #3536) (#3537) --- tachys/src/view/static_types.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tachys/src/view/static_types.rs b/tachys/src/view/static_types.rs index 234b3409a0..c1d18c26a8 100644 --- a/tachys/src/view/static_types.rs +++ b/tachys/src/view/static_types.rs @@ -3,7 +3,12 @@ use super::{ RenderHtml, ToTemplate, }; use crate::{ - html::attribute::{Attribute, AttributeKey, AttributeValue, NextAttribute}, + html::attribute::{ + maybe_next_attr_erasure_macros::{ + next_attr_combine, next_attr_output_type, + }, + Attribute, AttributeKey, AttributeValue, NextAttribute, + }, hydration::Cursor, renderer::{CastFrom, Rndr}, }; @@ -111,13 +116,13 @@ impl NextAttribute for StaticAttr where K: AttributeKey, { - type Output = (Self, NewAttr); + next_attr_output_type!(Self, NewAttr); fn add_any_attr( self, new_attr: NewAttr, ) -> Self::Output { - (StaticAttr:: { ty: PhantomData }, new_attr) + next_attr_combine!(StaticAttr:: { ty: PhantomData }, new_attr) } } From c6de7c714ea8f4022798afa2a56df336a844cc93 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sat, 1 Feb 2025 15:29:40 -0500 Subject: [PATCH 6/6] fix: emit syntax errors in components rather than swallowing them (closes #3535) (#3538) --- leptos_macro/src/lib.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/leptos_macro/src/lib.rs b/leptos_macro/src/lib.rs index 3599940884..dfd8851507 100644 --- a/leptos_macro/src/lib.rs +++ b/leptos_macro/src/lib.rs @@ -677,17 +677,21 @@ fn component_macro( #[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)] #unexpanded } - } else if let Ok(mut dummy) = dummy { - dummy.sig.ident = unmodified_fn_name_from_fn_name(&dummy.sig.ident); - quote! { - #[doc(hidden)] - #[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)] - #dummy - } } else { - quote! {} - } - .into() + match dummy { + Ok(mut dummy) => { + dummy.sig.ident = unmodified_fn_name_from_fn_name(&dummy.sig.ident); + quote! { + #[doc(hidden)] + #[allow(non_snake_case, dead_code, clippy::too_many_arguments, clippy::needless_lifetimes)] + #dummy + } + } + Err(e) => { + proc_macro_error2::abort!(e.span(), e); + } + } + }.into() } /// Annotates a struct so that it can be used with your Component as a `slot`.