From 2a4b80cf22f75b51741d342cdc1373262ba1850d Mon Sep 17 00:00:00 2001 From: zakstucke <44890343+zakstucke@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:32:57 +0200 Subject: [PATCH] feat: opt-in locations in release mode with --cfg locations (#3281) --- Cargo.toml | 3 + hydration_context/Cargo.toml | 3 + leptos/Cargo.toml | 3 + leptos_config/Cargo.toml | 3 + leptos_dom/Cargo.toml | 3 + leptos_macro/Cargo.toml | 2 +- leptos_server/Cargo.toml | 3 + leptos_server/src/action.rs | 18 ++--- leptos_server/src/local_resource.rs | 22 +++--- leptos_server/src/multi_action.rs | 18 ++--- leptos_server/src/once_resource.rs | 22 +++--- leptos_server/src/resource.rs | 26 +++---- meta/Cargo.toml | 3 + reactive_graph/Cargo.toml | 3 + reactive_graph/src/actions/action.rs | 30 ++++---- reactive_graph/src/actions/multi_action.rs | 8 +- reactive_graph/src/computed/arc_memo.rs | 12 +-- .../async_derived/arc_async_derived.rs | 14 ++-- .../computed/async_derived/async_derived.rs | 24 +++--- reactive_graph/src/computed/memo.rs | 16 ++-- reactive_graph/src/graph/source.rs | 7 +- reactive_graph/src/owner/arc_stored_value.rs | 12 +-- reactive_graph/src/owner/stored_value.rs | 10 +-- reactive_graph/src/signal/arc_read.rs | 10 +-- reactive_graph/src/signal/arc_rw.rs | 16 ++-- reactive_graph/src/signal/arc_trigger.rs | 10 +-- reactive_graph/src/signal/arc_write.rs | 8 +- reactive_graph/src/signal/read.rs | 10 +-- reactive_graph/src/signal/rw.rs | 20 ++--- .../src/signal/subscriber_traits.rs | 2 +- reactive_graph/src/signal/trigger.rs | 8 +- reactive_graph/src/signal/write.rs | 6 +- reactive_graph/src/traits.rs | 6 +- reactive_graph/src/wrappers.rs | 76 +++++++++---------- reactive_stores/Cargo.toml | 3 + reactive_stores/src/arc_field.rs | 18 ++--- reactive_stores/src/field.rs | 16 ++-- reactive_stores/src/iter.rs | 10 +-- reactive_stores/src/keyed.rs | 20 ++--- reactive_stores/src/lib.rs | 24 +++--- reactive_stores/src/subfield.rs | 10 +-- router_macro/Cargo.toml | 3 + server_fn/Cargo.toml | 3 + tachys/Cargo.toml | 3 + tachys/src/html/element/custom.rs | 2 +- tachys/src/html/element/elements.rs | 12 +-- tachys/src/html/element/mod.rs | 20 ++--- tachys/src/hydration.rs | 20 ++--- tachys/src/lib.rs | 12 +-- tachys/src/mathml/mod.rs | 10 +-- tachys/src/svg/mod.rs | 8 +- 51 files changed, 334 insertions(+), 297 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 159c761d5..6bdf3c6e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,3 +78,6 @@ opt-level = 'z' [workspace.metadata.cargo-all-features] skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]] + +[workspace.lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)', 'cfg(erase_components)'] } \ No newline at end of file diff --git a/hydration_context/Cargo.toml b/hydration_context/Cargo.toml index 987bb588b..3231d62f2 100644 --- a/hydration_context/Cargo.toml +++ b/hydration_context/Cargo.toml @@ -25,3 +25,6 @@ browser = ["dep:wasm-bindgen", "dep:js-sys"] [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/leptos/Cargo.toml b/leptos/Cargo.toml index 5ba94845a..bf0b0d33e 100644 --- a/leptos/Cargo.toml +++ b/leptos/Cargo.toml @@ -121,3 +121,6 @@ skip_feature_sets = [ [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/leptos_config/Cargo.toml b/leptos_config/Cargo.toml index f84892582..a8ad62b77 100644 --- a/leptos_config/Cargo.toml +++ b/leptos_config/Cargo.toml @@ -26,3 +26,6 @@ temp-env = { version = "0.3.6", features = ["async_closure"] } [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/leptos_dom/Cargo.toml b/leptos_dom/Cargo.toml index 4434911bf..2d057b823 100644 --- a/leptos_dom/Cargo.toml +++ b/leptos_dom/Cargo.toml @@ -37,3 +37,6 @@ rustdoc-args = ["--generate-link-to-definition"] [package.metadata.cargo-all-features] denylist = ["tracing"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index 358d90424..c54168140 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -83,4 +83,4 @@ skip_feature_sets = [ rustdoc-args = ["--generate-link-to-definition"] [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(erase_components)'] } +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)', 'cfg(erase_components)'] } diff --git a/leptos_server/Cargo.toml b/leptos_server/Cargo.toml index 3097d96a4..e93ac1c45 100644 --- a/leptos_server/Cargo.toml +++ b/leptos_server/Cargo.toml @@ -44,3 +44,6 @@ denylist = ["tracing"] [package.metadata.docs.rs] rustdoc-args = ["--generate-link-to-definition"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/leptos_server/src/action.rs b/leptos_server/src/action.rs index 177fb9cff..c66e75117 100644 --- a/leptos_server/src/action.rs +++ b/leptos_server/src/action.rs @@ -43,7 +43,7 @@ where S::Output: 'static, { inner: ArcAction>>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -65,7 +65,7 @@ where inner: ArcAction::new_with_value(err, |input: &S| { S::run_on_client(input.clone()) }), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -91,7 +91,7 @@ where fn clone(&self) -> Self { Self { inner: self.inner.clone(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, } } @@ -114,11 +114,11 @@ where S::Output: 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -132,7 +132,7 @@ where S::Output: 'static, { inner: Action>>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -153,7 +153,7 @@ where inner: Action::new_with_value(err, |input: &S| { S::run_on_client(input.clone()) }), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -217,11 +217,11 @@ where S::Output: 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/leptos_server/src/local_resource.rs b/leptos_server/src/local_resource.rs index d74427375..9519571c7 100644 --- a/leptos_server/src/local_resource.rs +++ b/leptos_server/src/local_resource.rs @@ -20,7 +20,7 @@ use std::{ /// A reference-counted resource that only loads its data locally on the client. pub struct ArcLocalResource { data: ArcAsyncDerived>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -28,7 +28,7 @@ impl Clone for ArcLocalResource { fn clone(&self) -> Self { Self { data: self.data.clone(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, } } @@ -70,7 +70,7 @@ impl ArcLocalResource { let fut = fetcher(); SendWrapper::new(async move { SendWrapper::new(fut.await) }) }), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -104,11 +104,11 @@ where impl DefinedAt for ArcLocalResource { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -200,7 +200,7 @@ impl Subscriber for ArcLocalResource { /// A resource that only loads its data locally on the client. pub struct LocalResource { data: AsyncDerived>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -253,7 +253,7 @@ impl LocalResource { SendWrapper::new(async move { SendWrapper::new(fut.await) }) }) }, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -287,11 +287,11 @@ where impl DefinedAt for LocalResource { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -398,7 +398,7 @@ impl From> for LocalResource { fn from(arc: ArcLocalResource) -> Self { Self { data: arc.data.into(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: arc.defined_at, } } @@ -408,7 +408,7 @@ impl From> for ArcLocalResource { fn from(local: LocalResource) -> Self { Self { data: local.data.into(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: local.defined_at, } } diff --git a/leptos_server/src/multi_action.rs b/leptos_server/src/multi_action.rs index d62a6a905..e33a873bf 100644 --- a/leptos_server/src/multi_action.rs +++ b/leptos_server/src/multi_action.rs @@ -12,7 +12,7 @@ where S::Output: 'static, { inner: ArcMultiAction>>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -29,7 +29,7 @@ where inner: ArcMultiAction::new(|input: &S| { S::run_on_client(input.clone()) }), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -55,7 +55,7 @@ where fn clone(&self) -> Self { Self { inner: self.inner.clone(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, } } @@ -78,11 +78,11 @@ where S::Output: 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -96,7 +96,7 @@ where S::Output: 'static, { inner: MultiAction>>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -123,7 +123,7 @@ where inner: MultiAction::new(|input: &S| { S::run_on_client(input.clone()) }), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -176,11 +176,11 @@ where S::Output: 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/leptos_server/src/once_resource.rs b/leptos_server/src/once_resource.rs index 3ab0b0054..a1155c35e 100644 --- a/leptos_server/src/once_resource.rs +++ b/leptos_server/src/once_resource.rs @@ -60,7 +60,7 @@ pub struct ArcOnceResource { suspenses: Arc>>, loading: Arc, ser: PhantomData Ser>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -73,7 +73,7 @@ impl Clone for ArcOnceResource { suspenses: self.suspenses.clone(), loading: self.loading.clone(), ser: self.ser, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, } } @@ -140,7 +140,7 @@ where wakers, suspenses, ser: PhantomData, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), }; @@ -183,11 +183,11 @@ impl ArcOnceResource { impl DefinedAt for ArcOnceResource { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } @@ -272,7 +272,7 @@ where #[track_caller] fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let _guard = SpecialNonReactiveZone::enter(); let waker = cx.waker(); self.source.track(); @@ -491,7 +491,7 @@ where #[derive(Debug)] pub struct OnceResource { inner: ArenaItem>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -524,13 +524,13 @@ where fut: impl Future + Send + 'static, blocking: bool, ) -> Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let defined_at = Location::caller(); Self { inner: ArenaItem::new(ArcOnceResource::new_with_options( fut, blocking, )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, } } @@ -551,11 +551,11 @@ where impl DefinedAt for OnceResource { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } diff --git a/leptos_server/src/resource.rs b/leptos_server/src/resource.rs index f5ca00017..9bedf8dd3 100644 --- a/leptos_server/src/resource.rs +++ b/leptos_server/src/resource.rs @@ -74,7 +74,7 @@ pub struct ArcResource { ser: PhantomData, refetch: ArcRwSignal, data: ArcAsyncDerived, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -82,7 +82,7 @@ impl Debug for ArcResource { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut d = f.debug_struct("ArcResource"); d.field("ser", &self.ser).field("data", &self.data); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] d.field("defined_at", self.defined_at); d.finish_non_exhaustive() } @@ -98,7 +98,7 @@ where ser: PhantomData, data: arc_resource.data.into(), refetch: arc_resource.refetch.into(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -114,7 +114,7 @@ where ser: PhantomData, data: resource.data.into(), refetch: resource.refetch.into(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -122,11 +122,11 @@ where impl DefinedAt for ArcResource { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -139,7 +139,7 @@ impl Clone for ArcResource { ser: self.ser, refetch: self.refetch.clone(), data: self.data.clone(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, } } @@ -300,7 +300,7 @@ where ser: PhantomData, data, refetch, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -781,7 +781,7 @@ where ser: PhantomData, data: AsyncDerived, refetch: RwSignal, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -792,7 +792,7 @@ where fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut d = f.debug_struct("ArcResource"); d.field("ser", &self.ser).field("data", &self.data); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] d.field("defined_at", self.defined_at); d.finish_non_exhaustive() } @@ -803,11 +803,11 @@ where T: Send + Sync + 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -1270,7 +1270,7 @@ where ser: PhantomData, data: data.into(), refetch: refetch.into(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } diff --git a/meta/Cargo.toml b/meta/Cargo.toml index 4fe839c0e..f6cdbd654 100644 --- a/meta/Cargo.toml +++ b/meta/Cargo.toml @@ -32,3 +32,6 @@ rustdoc-args = ["--generate-link-to-definition"] [package.metadata.cargo-all-features] denylist = ["tracing"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/reactive_graph/Cargo.toml b/reactive_graph/Cargo.toml index 015a1447d..f66a2aca6 100644 --- a/reactive_graph/Cargo.toml +++ b/reactive_graph/Cargo.toml @@ -47,3 +47,6 @@ rustdoc-args = ["--cfg", "docsrs"] [package.metadata.cargo-all-features] denylist = ["tracing"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/reactive_graph/src/actions/action.rs b/reactive_graph/src/actions/action.rs index 504f8aee4..077abec3f 100644 --- a/reactive_graph/src/actions/action.rs +++ b/reactive_graph/src/actions/action.rs @@ -101,7 +101,7 @@ pub struct ArcAction { action_fn: Arc< dyn Fn(&I) -> Pin + Send>> + Send + Sync, >, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -114,7 +114,7 @@ impl Clone for ArcAction { version: self.version.clone(), dispatched: self.dispatched.clone(), action_fn: self.action_fn.clone(), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, } } @@ -198,7 +198,7 @@ where version: Default::default(), dispatched: Default::default(), action_fn: Arc::new(move |input| Box::pin(action_fn(input))), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -370,7 +370,7 @@ where action_fn: Arc::new(move |input| { Box::pin(SendWrapper::new(action_fn(input))) }), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -502,11 +502,11 @@ where O: 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -592,7 +592,7 @@ where /// ``` pub struct Action { inner: ArenaItem, S>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -656,7 +656,7 @@ where { Self { inner: ArenaItem::new(ArcAction::new(action_fn)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -681,7 +681,7 @@ where { Self { inner: ArenaItem::new(ArcAction::new_with_value(value, action_fn)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -719,7 +719,7 @@ where { Self { inner: ArenaItem::new_local(ArcAction::new_unsync(action_fn)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -737,7 +737,7 @@ where inner: ArenaItem::new_local(ArcAction::new_unsync_with_value( value, action_fn, )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -979,7 +979,7 @@ where inner: ArenaItem::new_with_storage(ArcAction::new_unsync( action_fn, )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -998,7 +998,7 @@ where inner: ArenaItem::new_with_storage( ArcAction::new_unsync_with_value(value, action_fn), ), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -1006,11 +1006,11 @@ where impl DefinedAt for Action { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/actions/multi_action.rs b/reactive_graph/src/actions/multi_action.rs index fe59c8da8..c4d8e674b 100644 --- a/reactive_graph/src/actions/multi_action.rs +++ b/reactive_graph/src/actions/multi_action.rs @@ -46,7 +46,7 @@ use std::{fmt::Debug, future::Future, panic::Location, pin::Pin, sync::Arc}; /// ``` pub struct MultiAction { inner: ArenaItem, S>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -62,11 +62,11 @@ where O: 'static, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -130,7 +130,7 @@ where { Self { inner: ArenaItem::new_with_storage(ArcMultiAction::new(action_fn)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } diff --git a/reactive_graph/src/computed/arc_memo.rs b/reactive_graph/src/computed/arc_memo.rs index f70463ff1..490f09754 100644 --- a/reactive_graph/src/computed/arc_memo.rs +++ b/reactive_graph/src/computed/arc_memo.rs @@ -93,7 +93,7 @@ pub struct ArcMemo where S: Storage, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: Arc>>, } @@ -164,7 +164,7 @@ where RwLock::new(MemoInner::new(Arc::new(fun), subscriber)) }); Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner, } @@ -177,7 +177,7 @@ where { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, inner: Arc::clone(&self.inner), } @@ -190,11 +190,11 @@ where { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -272,7 +272,7 @@ where AnySource( Arc::as_ptr(&self.inner) as usize, Arc::downgrade(&self.inner) as Weak, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] self.defined_at, ) } diff --git a/reactive_graph/src/computed/async_derived/arc_async_derived.rs b/reactive_graph/src/computed/async_derived/arc_async_derived.rs index ecb747299..b31f82aaa 100644 --- a/reactive_graph/src/computed/async_derived/arc_async_derived.rs +++ b/reactive_graph/src/computed/async_derived/arc_async_derived.rs @@ -107,7 +107,7 @@ use std::{ /// - [`IntoFuture`](std::future::Future) allows you to create a [`Future`] that resolves /// when this resource is done loading. pub struct ArcAsyncDerived { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, // the current state of this signal pub(crate) value: Arc>>, @@ -184,7 +184,7 @@ impl BlockingLock for AsyncRwLock { impl Clone for ArcAsyncDerived { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, value: Arc::clone(&self.value), wakers: Arc::clone(&self.wakers), @@ -197,7 +197,7 @@ impl Clone for ArcAsyncDerived { impl Debug for ArcAsyncDerived { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut f = f.debug_struct("ArcAsyncDerived"); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] f.field("defined_at", &self.defined_at); f.finish_non_exhaustive() } @@ -206,11 +206,11 @@ impl Debug for ArcAsyncDerived { impl DefinedAt for ArcAsyncDerived { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -241,7 +241,7 @@ macro_rules! spawn_derived { let wakers = Arc::new(RwLock::new(Vec::new())); let this = ArcAsyncDerived { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::clone(&value), wakers, @@ -632,7 +632,7 @@ impl ToAnySource for ArcAsyncDerived { AnySource( Arc::as_ptr(&self.inner) as usize, Arc::downgrade(&self.inner) as Weak, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] self.defined_at, ) } diff --git a/reactive_graph/src/computed/async_derived/async_derived.rs b/reactive_graph/src/computed/async_derived/async_derived.rs index 9a181decb..41e3f5d40 100644 --- a/reactive_graph/src/computed/async_derived/async_derived.rs +++ b/reactive_graph/src/computed/async_derived/async_derived.rs @@ -83,7 +83,7 @@ use std::{future::Future, ops::DerefMut, panic::Location}; /// - [`IntoFuture`](std::future::Future) allows you to create a [`Future`] that resolves /// when this resource is done loading. pub struct AsyncDerived { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, pub(crate) inner: ArenaItem, S>, } @@ -99,10 +99,10 @@ where T: Send + Sync + 'static, { fn from(value: ArcAsyncDerived) -> Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let defined_at = value.defined_at; Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, inner: ArenaItem::new_with_storage(value), } @@ -127,10 +127,10 @@ where T: 'static, { fn from_local(value: ArcAsyncDerived) -> Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let defined_at = value.defined_at; Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, inner: ArenaItem::new_with_storage(value), } @@ -152,7 +152,7 @@ where Fut: Future + Send + 'static, { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcAsyncDerived::new(fun)), } @@ -170,7 +170,7 @@ where Fut: Future + Send + 'static, { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage( ArcAsyncDerived::new_with_initial(initial_value, fun), @@ -187,7 +187,7 @@ impl AsyncDerived> { Fut: Future + 'static, { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcAsyncDerived::new_mock(fun)), } @@ -209,7 +209,7 @@ where Fut: Future + 'static, { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcAsyncDerived::new_unsync( fun, @@ -230,7 +230,7 @@ where Fut: Future + 'static, { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage( ArcAsyncDerived::new_unsync_with_initial(initial_value, fun), @@ -278,11 +278,11 @@ where impl DefinedAt for AsyncDerived { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/computed/memo.rs b/reactive_graph/src/computed/memo.rs index d50fd8622..83263b68c 100644 --- a/reactive_graph/src/computed/memo.rs +++ b/reactive_graph/src/computed/memo.rs @@ -100,7 +100,7 @@ pub struct Memo where S: Storage, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: ArenaItem, S>, } @@ -121,7 +121,7 @@ where #[track_caller] fn from(value: ArcMemo) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value), } @@ -135,7 +135,7 @@ where #[track_caller] fn from_local(value: ArcMemo) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value), } @@ -175,7 +175,7 @@ where T: PartialEq, { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcMemo::new(fun)), } @@ -197,7 +197,7 @@ where changed: fn(Option<&T>, Option<&T>) -> bool, ) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcMemo::new_with_compare( fun, changed, @@ -221,7 +221,7 @@ where fun: impl Fn(Option) -> (T, bool) + Send + Sync + 'static, ) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcMemo::new_owning(fun)), } @@ -276,11 +276,11 @@ where S: Storage, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/graph/source.rs b/reactive_graph/src/graph/source.rs index 07d1fce2e..1b2e724dc 100644 --- a/reactive_graph/src/graph/source.rs +++ b/reactive_graph/src/graph/source.rs @@ -26,16 +26,17 @@ pub trait Source: ReactiveNode { pub struct AnySource( pub(crate) usize, pub(crate) Weak, - #[cfg(debug_assertions)] pub(crate) &'static Location<'static>, + #[cfg(any(debug_assertions, leptos_debuginfo))] + pub(crate) &'static Location<'static>, ); impl DefinedAt for AnySource { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.2) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/owner/arc_stored_value.rs b/reactive_graph/src/owner/arc_stored_value.rs index aee18270b..cb32819fc 100644 --- a/reactive_graph/src/owner/arc_stored_value.rs +++ b/reactive_graph/src/owner/arc_stored_value.rs @@ -19,7 +19,7 @@ use std::{ /// accessing it does not cause effects to subscribe, and /// updating it does not notify anything else. pub struct ArcStoredValue { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, value: Arc>, } @@ -27,7 +27,7 @@ pub struct ArcStoredValue { impl Clone for ArcStoredValue { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, value: Arc::clone(&self.value), } @@ -47,7 +47,7 @@ impl Default for ArcStoredValue { #[track_caller] fn default() -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::new(RwLock::new(T::default())), } @@ -70,11 +70,11 @@ impl Hash for ArcStoredValue { impl DefinedAt for ArcStoredValue { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -90,7 +90,7 @@ impl ArcStoredValue { #[track_caller] pub fn new(value: T) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::new(RwLock::new(value)), } diff --git a/reactive_graph/src/owner/stored_value.rs b/reactive_graph/src/owner/stored_value.rs index d3c991632..8976ea3e3 100644 --- a/reactive_graph/src/owner/stored_value.rs +++ b/reactive_graph/src/owner/stored_value.rs @@ -22,7 +22,7 @@ use std::{ /// updating it does not notify anything else. pub struct StoredValue { value: ArenaItem, S>, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, } @@ -62,11 +62,11 @@ impl Hash for StoredValue { impl DefinedAt for StoredValue { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -83,7 +83,7 @@ where pub fn new_with_storage(value: T) -> Self { Self { value: ArenaItem::new_with_storage(ArcStoredValue::new(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), } } @@ -169,7 +169,7 @@ where #[track_caller] fn from(value: ArcStoredValue) -> Self { StoredValue { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: ArenaItem::new(value), } diff --git a/reactive_graph/src/signal/arc_read.rs b/reactive_graph/src/signal/arc_read.rs index b4a62567d..2d6405a55 100644 --- a/reactive_graph/src/signal/arc_read.rs +++ b/reactive_graph/src/signal/arc_read.rs @@ -54,7 +54,7 @@ use std::{ /// assert_eq!(count.read(), 0); /// ``` pub struct ArcReadSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) value: Arc>, pub(crate) inner: Arc>, @@ -64,7 +64,7 @@ impl Clone for ArcReadSignal { #[track_caller] fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, value: Arc::clone(&self.value), inner: Arc::clone(&self.inner), @@ -85,7 +85,7 @@ impl Default for ArcReadSignal { #[track_caller] fn default() -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::new(RwLock::new(T::default())), inner: Arc::new(RwLock::new(SubscriberSet::new())), @@ -110,11 +110,11 @@ impl Hash for ArcReadSignal { impl DefinedAt for ArcReadSignal { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/signal/arc_rw.rs b/reactive_graph/src/signal/arc_rw.rs index cd18e3b4e..b4e67a033 100644 --- a/reactive_graph/src/signal/arc_rw.rs +++ b/reactive_graph/src/signal/arc_rw.rs @@ -94,7 +94,7 @@ use std::{ /// assert_eq!(double_count(), 2); /// ``` pub struct ArcRwSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) value: Arc>, pub(crate) inner: Arc>, @@ -104,7 +104,7 @@ impl Clone for ArcRwSignal { #[track_caller] fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, value: Arc::clone(&self.value), inner: Arc::clone(&self.inner), @@ -154,7 +154,7 @@ impl ArcRwSignal { #[track_caller] pub fn new(value: T) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::new(RwLock::new(value)), inner: Arc::new(RwLock::new(SubscriberSet::new())), @@ -165,7 +165,7 @@ impl ArcRwSignal { #[track_caller] pub fn read_only(&self) -> ArcReadSignal { ArcReadSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::clone(&self.value), inner: Arc::clone(&self.inner), @@ -176,7 +176,7 @@ impl ArcRwSignal { #[track_caller] pub fn write_only(&self) -> ArcWriteSignal { ArcWriteSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::clone(&self.value), inner: Arc::clone(&self.inner), @@ -198,7 +198,7 @@ impl ArcRwSignal { ) -> Option { if Arc::ptr_eq(&read.inner, &write.inner) { Some(Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: read.value, inner: read.inner, @@ -212,11 +212,11 @@ impl ArcRwSignal { impl DefinedAt for ArcRwSignal { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/signal/arc_trigger.rs b/reactive_graph/src/signal/arc_trigger.rs index e1a7cedee..583c57f4a 100644 --- a/reactive_graph/src/signal/arc_trigger.rs +++ b/reactive_graph/src/signal/arc_trigger.rs @@ -13,7 +13,7 @@ use std::{ /// /// This can be useful for when using external data not stored in signals, for example. pub struct ArcTrigger { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) inner: Arc>, } @@ -23,7 +23,7 @@ impl ArcTrigger { #[track_caller] pub fn new() -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: Default::default(), } @@ -40,7 +40,7 @@ impl Clone for ArcTrigger { #[track_caller] fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, inner: Arc::clone(&self.inner), } @@ -72,11 +72,11 @@ impl AsSubscriberSet for ArcTrigger { impl DefinedAt for ArcTrigger { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/signal/arc_write.rs b/reactive_graph/src/signal/arc_write.rs index 580b55a0f..1426983b8 100644 --- a/reactive_graph/src/signal/arc_write.rs +++ b/reactive_graph/src/signal/arc_write.rs @@ -54,7 +54,7 @@ use std::{ /// assert_eq!(count.get(), 3); /// ``` pub struct ArcWriteSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) value: Arc>, pub(crate) inner: Arc>, @@ -64,7 +64,7 @@ impl Clone for ArcWriteSignal { #[track_caller] fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, value: Arc::clone(&self.value), inner: Arc::clone(&self.inner), @@ -98,11 +98,11 @@ impl Hash for ArcWriteSignal { impl DefinedAt for ArcWriteSignal { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/signal/read.rs b/reactive_graph/src/signal/read.rs index af7ec1216..f2bf7a614 100644 --- a/reactive_graph/src/signal/read.rs +++ b/reactive_graph/src/signal/read.rs @@ -58,7 +58,7 @@ use std::{ /// assert_eq!(count.read(), 0); /// ``` pub struct ReadSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) inner: ArenaItem, S>, } @@ -105,11 +105,11 @@ impl Hash for ReadSignal { impl DefinedAt for ReadSignal { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -156,7 +156,7 @@ where #[track_caller] fn from(value: ArcReadSignal) -> Self { ReadSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value), } @@ -170,7 +170,7 @@ where #[track_caller] fn from_local(value: ArcReadSignal) -> Self { ReadSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value), } diff --git a/reactive_graph/src/signal/rw.rs b/reactive_graph/src/signal/rw.rs index 91310b734..69097e029 100644 --- a/reactive_graph/src/signal/rw.rs +++ b/reactive_graph/src/signal/rw.rs @@ -100,7 +100,7 @@ use std::{ /// assert_eq!(double_count(), 2); /// ``` pub struct RwSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: ArenaItem, S>, } @@ -139,7 +139,7 @@ where #[track_caller] pub fn new_with_storage(value: T) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcRwSignal::new(value)), } @@ -172,7 +172,7 @@ where #[track_caller] pub fn read_only(&self) -> ReadSignal { ReadSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage( self.inner @@ -194,7 +194,7 @@ where #[track_caller] pub fn write_only(&self) -> WriteSignal { WriteSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage( self.inner @@ -231,10 +231,10 @@ where (Some(read), Some(write)) => { if Arc::ptr_eq(&read.inner, &write.inner) { Some(Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcRwSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::clone(&read.value), inner: Arc::clone(&read.inner), @@ -296,11 +296,11 @@ impl Hash for RwSignal { impl DefinedAt for RwSignal { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -378,7 +378,7 @@ where #[track_caller] fn from(value: ArcRwSignal) -> Self { RwSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value), } @@ -402,7 +402,7 @@ where #[track_caller] fn from_local(value: ArcRwSignal) -> Self { RwSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value), } diff --git a/reactive_graph/src/signal/subscriber_traits.rs b/reactive_graph/src/signal/subscriber_traits.rs index 5fb15ba5f..07161ea64 100644 --- a/reactive_graph/src/signal/subscriber_traits.rs +++ b/reactive_graph/src/signal/subscriber_traits.rs @@ -105,7 +105,7 @@ where AnySource( Arc::as_ptr(subs) as usize, Arc::downgrade(subs) as Weak, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] self.defined_at().expect("no DefinedAt in debug mode"), ) }) diff --git a/reactive_graph/src/signal/trigger.rs b/reactive_graph/src/signal/trigger.rs index 137f76f46..226310655 100644 --- a/reactive_graph/src/signal/trigger.rs +++ b/reactive_graph/src/signal/trigger.rs @@ -18,7 +18,7 @@ use std::{ /// [`Owner`](crate::owner::Owner) cleans up. For a reference-counted trigger that lives /// as long as a reference to it is alive, see [`ArcTrigger`]. pub struct Trigger { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) inner: ArenaItem, } @@ -28,7 +28,7 @@ impl Trigger { #[track_caller] pub fn new() -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new(ArcTrigger::new()), } @@ -83,11 +83,11 @@ impl AsSubscriberSet for Trigger { impl DefinedAt for Trigger { #[inline(always)] fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/signal/write.rs b/reactive_graph/src/signal/write.rs index 2be0e8e69..985122fd6 100644 --- a/reactive_graph/src/signal/write.rs +++ b/reactive_graph/src/signal/write.rs @@ -50,7 +50,7 @@ use std::{hash::Hash, ops::DerefMut, panic::Location, sync::Arc}; /// assert_eq!(count.get(), 3); /// ``` pub struct WriteSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) inner: ArenaItem, S>, } @@ -97,11 +97,11 @@ impl Hash for WriteSignal { impl DefinedAt for WriteSignal { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_graph/src/traits.rs b/reactive_graph/src/traits.rs index 540fc5fd1..63bdc0fa4 100644 --- a/reactive_graph/src/traits.rs +++ b/reactive_graph/src/traits.rs @@ -67,10 +67,10 @@ use std::{ #[macro_export] macro_rules! unwrap_signal { ($signal:ident) => {{ - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let location = std::panic::Location::caller(); || { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { panic!( "{}", @@ -80,7 +80,7 @@ macro_rules! unwrap_signal { ) ); } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { panic!( "Tried to access a reactive value that has already been \ diff --git a/reactive_graph/src/wrappers.rs b/reactive_graph/src/wrappers.rs index 75c9d283f..fb3b86640 100644 --- a/reactive_graph/src/wrappers.rs +++ b/reactive_graph/src/wrappers.rs @@ -103,7 +103,7 @@ pub mod read { where S: Storage, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: SignalTypes, } @@ -114,7 +114,7 @@ pub mod read { { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, inner: self.inner.clone(), } @@ -128,7 +128,7 @@ pub mod read { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut s = f.debug_struct("ArcSignal"); s.field("inner", &self.inner); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] s.field("defined_at", &self.defined_at); s.finish() } @@ -184,7 +184,7 @@ pub mod read { Self { inner: SignalTypes::DerivedSignal(Arc::new(derived_signal)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -194,7 +194,7 @@ pub mod read { pub fn stored(value: T) -> Self { Self { inner: SignalTypes::Stored(ArcStoredValue::new(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -214,7 +214,7 @@ pub mod read { fn from(value: ArcReadSignal) -> Self { Self { inner: SignalTypes::ReadSignal(value), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -225,7 +225,7 @@ pub mod read { fn from(value: ArcRwSignal) -> Self { Self { inner: SignalTypes::ReadSignal(value.read_only()), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -239,7 +239,7 @@ pub mod read { fn from(value: ArcMemo) -> Self { Self { inner: SignalTypes::Memo(value), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -250,11 +250,11 @@ pub mod read { S: Storage, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -339,7 +339,7 @@ pub mod read { where S: Storage, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: ArenaItem, S>, } @@ -371,7 +371,7 @@ pub mod read { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut s = f.debug_struct("Signal"); s.field("inner", &self.inner); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] s.field("defined_at", &self.defined_at); s.finish() } @@ -393,11 +393,11 @@ pub mod read { S: Storage, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -530,7 +530,7 @@ pub mod read { inner: ArenaItem::new_with_storage(SignalTypes::DerivedSignal( Arc::new(derived_signal), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -542,7 +542,7 @@ pub mod read { inner: ArenaItem::new_with_storage(SignalTypes::Stored( ArcStoredValue::new(value), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -569,7 +569,7 @@ pub mod read { inner: ArenaItem::new_local(SignalTypes::DerivedSignal( Arc::new(derived_signal), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -582,7 +582,7 @@ pub mod read { inner: ArenaItem::new_local(SignalTypes::Stored( ArcStoredValue::new(value), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -640,7 +640,7 @@ pub mod read { #[track_caller] fn from(value: ArcSignal) -> Self { Signal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new(value.inner), } @@ -654,7 +654,7 @@ pub mod read { #[track_caller] fn from_local(value: ArcSignal) -> Self { Signal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_local(value.inner), } @@ -668,7 +668,7 @@ pub mod read { #[track_caller] fn from(value: Signal) -> Self { ArcSignal { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: value .inner @@ -686,7 +686,7 @@ pub mod read { fn from(value: ReadSignal) -> Self { Self { inner: ArenaItem::new(SignalTypes::ReadSignal(value.into())), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -702,7 +702,7 @@ pub mod read { inner: ArenaItem::new_local(SignalTypes::ReadSignal( value.into(), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -716,7 +716,7 @@ pub mod read { fn from(value: ArcReadSignal) -> Self { Self { inner: ArenaItem::new(SignalTypes::ReadSignal(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -730,7 +730,7 @@ pub mod read { fn from(value: ArcReadSignal) -> Self { Self { inner: ArenaItem::new_local(SignalTypes::ReadSignal(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -746,7 +746,7 @@ pub mod read { inner: ArenaItem::new(SignalTypes::ReadSignal( value.read_only().into(), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -762,7 +762,7 @@ pub mod read { inner: ArenaItem::new_local(SignalTypes::ReadSignal( value.read_only().into(), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -778,7 +778,7 @@ pub mod read { inner: ArenaItem::new(SignalTypes::ReadSignal( value.read_only(), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -794,7 +794,7 @@ pub mod read { inner: ArenaItem::new_local(SignalTypes::ReadSignal( value.read_only(), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -808,7 +808,7 @@ pub mod read { fn from(value: Memo) -> Self { Self { inner: ArenaItem::new(SignalTypes::Memo(value.into())), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -822,7 +822,7 @@ pub mod read { fn from(value: Memo) -> Self { Self { inner: ArenaItem::new_local(SignalTypes::Memo(value.into())), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -836,7 +836,7 @@ pub mod read { fn from(value: ArcMemo) -> Self { Self { inner: ArenaItem::new(SignalTypes::Memo(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -850,7 +850,7 @@ pub mod read { fn from(value: ArcMemo) -> Self { Self { inner: ArenaItem::new_local(SignalTypes::Memo(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -1831,7 +1831,7 @@ pub mod write { T: 'static, { inner: SignalSetterTypes, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static std::panic::Location<'static>, } @@ -1846,7 +1846,7 @@ pub mod write { fn default() -> Self { Self { inner: SignalSetterTypes::Default, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -1899,7 +1899,7 @@ pub mod write { inner: SignalSetterTypes::Mapped(ArenaItem::new_with_storage( Box::new(mapped_setter), )), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -1910,7 +1910,7 @@ pub mod write { fn from(value: WriteSignal) -> Self { Self { inner: SignalSetterTypes::Write(value), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } @@ -1925,7 +1925,7 @@ pub mod write { fn from(value: RwSignal) -> Self { Self { inner: SignalSetterTypes::Write(value.write_only()), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), } } diff --git a/reactive_stores/Cargo.toml b/reactive_stores/Cargo.toml index 98b5792b6..b7c4a8b68 100644 --- a/reactive_stores/Cargo.toml +++ b/reactive_stores/Cargo.toml @@ -23,3 +23,6 @@ tokio = { version = "1.41", features = ["rt-multi-thread", "macros"] } tokio-test = { version = "0.4.4" } any_spawner = { workspace = true, features = ["futures-executor", "tokio"] } reactive_graph = { workspace = true, features = ["effects"] } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/reactive_stores/src/arc_field.rs b/reactive_stores/src/arc_field.rs index baa66eb4c..cf80e2dcc 100644 --- a/reactive_stores/src/arc_field.rs +++ b/reactive_stores/src/arc_field.rs @@ -26,7 +26,7 @@ pub struct ArcField where T: 'static, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, path: StorePath, trigger: StoreFieldTrigger, @@ -116,7 +116,7 @@ where #[track_caller] fn from(value: Store) -> Self { ArcField { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), path: value.path().into_iter().collect(), trigger: value.get_trigger(value.path().into_iter().collect()), @@ -136,7 +136,7 @@ where #[track_caller] fn from(value: ArcStore) -> Self { ArcField { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), path: value.path().into_iter().collect(), trigger: value.get_trigger(value.path().into_iter().collect()), @@ -174,7 +174,7 @@ where #[track_caller] fn from(value: Subfield) -> Self { ArcField { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), path: value.path().into_iter().collect(), trigger: value.get_trigger(value.path().into_iter().collect()), @@ -212,7 +212,7 @@ where #[track_caller] fn from(value: AtIndex) -> Self { ArcField { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), path: value.path().into_iter().collect(), trigger: value.get_trigger(value.path().into_iter().collect()), @@ -254,7 +254,7 @@ where #[track_caller] fn from(value: AtKeyed) -> Self { ArcField { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), path: value.path().into_iter().collect(), trigger: value.get_trigger(value.path().into_iter().collect()), @@ -285,7 +285,7 @@ where impl Clone for ArcField { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, path: self.path.clone(), trigger: self.trigger.clone(), @@ -300,11 +300,11 @@ impl Clone for ArcField { impl DefinedAt for ArcField { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_stores/src/field.rs b/reactive_stores/src/field.rs index d92a1e3fc..65a372293 100644 --- a/reactive_stores/src/field.rs +++ b/reactive_stores/src/field.rs @@ -27,7 +27,7 @@ pub struct Field where T: 'static, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: ArenaItem, S>, } @@ -75,7 +75,7 @@ where #[track_caller] fn from(value: Store) -> Self { Field { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value.into()), } @@ -90,7 +90,7 @@ where #[track_caller] fn from(value: ArcStore) -> Self { Field { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value.into()), } @@ -108,7 +108,7 @@ where #[track_caller] fn from(value: Subfield) -> Self { Field { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value.into()), } @@ -126,7 +126,7 @@ where #[track_caller] fn from(value: AtIndex) -> Self { Field { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value.into()), } @@ -149,7 +149,7 @@ where #[track_caller] fn from(value: AtKeyed) -> Self { Field { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(value.into()), } @@ -166,11 +166,11 @@ impl Copy for Field {} impl DefinedAt for Field { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_stores/src/iter.rs b/reactive_stores/src/iter.rs index 9a41af566..72dfba036 100644 --- a/reactive_stores/src/iter.rs +++ b/reactive_stores/src/iter.rs @@ -23,7 +23,7 @@ use std::{ /// Provides access to the data at some index in another collection. #[derive(Debug)] pub struct AtIndex { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: Inner, index: usize, @@ -36,7 +36,7 @@ where { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, inner: self.inner.clone(), index: self.index, @@ -52,7 +52,7 @@ impl AtIndex { #[track_caller] pub fn new(inner: Inner, index: usize) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner, index, @@ -115,11 +115,11 @@ where Inner: StoreField, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_stores/src/keyed.rs b/reactive_stores/src/keyed.rs index 4d9a4273f..b111be182 100644 --- a/reactive_stores/src/keyed.rs +++ b/reactive_stores/src/keyed.rs @@ -28,7 +28,7 @@ pub struct KeyedSubfield where for<'a> &'a T: IntoIterator, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, path_segment: StorePathSegment, inner: Inner, @@ -44,7 +44,7 @@ where { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, path_segment: self.path_segment, inner: self.inner.clone(), @@ -76,7 +76,7 @@ where write: fn(&mut Prev) -> &mut T, ) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner, path_segment, @@ -254,11 +254,11 @@ where Inner: StoreField, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -356,7 +356,7 @@ pub struct AtKeyed where for<'a> &'a T: IntoIterator, { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: KeyedSubfield, key: K, @@ -370,7 +370,7 @@ where { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, inner: self.inner.clone(), key: self.key.clone(), @@ -394,7 +394,7 @@ where #[track_caller] pub fn new(inner: KeyedSubfield, key: K) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner, key, @@ -511,11 +511,11 @@ where for<'a> &'a T: IntoIterator, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_stores/src/lib.rs b/reactive_stores/src/lib.rs index 8c1e095f6..92a780fdc 100644 --- a/reactive_stores/src/lib.rs +++ b/reactive_stores/src/lib.rs @@ -315,7 +315,7 @@ impl KeyMap { /// This adds a getter method for each field to `Store`, which allow accessing reactive versions /// of each individual field of the struct. pub struct ArcStore { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, pub(crate) value: Arc>, signals: Arc>, @@ -326,7 +326,7 @@ impl ArcStore { /// Creates a new store from the initial value. pub fn new(value: T) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), value: Arc::new(RwLock::new(value)), signals: Default::default(), @@ -338,7 +338,7 @@ impl ArcStore { impl Debug for ArcStore { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut f = f.debug_struct("ArcStore"); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let f = f.field("defined_at", &self.defined_at); f.field("value", &self.value) .field("signals", &self.signals) @@ -349,7 +349,7 @@ impl Debug for ArcStore { impl Clone for ArcStore { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, value: Arc::clone(&self.value), signals: Arc::clone(&self.signals), @@ -360,11 +360,11 @@ impl Clone for ArcStore { impl DefinedAt for ArcStore { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } @@ -433,7 +433,7 @@ impl Notify for ArcStore { /// This follows the same ownership rules as arena-allocated types like /// [`RwSignal`](reactive_graph::signal::RwSignal). pub struct Store { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, inner: ArenaItem, S>, } @@ -445,7 +445,7 @@ where /// Creates a new store with the initial value. pub fn new(value: T) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcStore::new(value)), } @@ -461,7 +461,7 @@ where /// This pins the value to the current thread. Accessing it from any other thread will panic. pub fn new_local(value: T) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner: ArenaItem::new_with_storage(ArcStore::new(value)), } @@ -474,7 +474,7 @@ where { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut f = f.debug_struct("Store"); - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] let f = f.field("defined_at", &self.defined_at); f.field("inner", &self.inner).finish() } @@ -490,11 +490,11 @@ impl Copy for Store {} impl DefinedAt for Store { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/reactive_stores/src/subfield.rs b/reactive_stores/src/subfield.rs index 34f979f1e..9a2d4a4d5 100644 --- a/reactive_stores/src/subfield.rs +++ b/reactive_stores/src/subfield.rs @@ -18,7 +18,7 @@ use std::{iter, marker::PhantomData, ops::DerefMut, panic::Location}; /// Accesses a single field of a reactive structure. #[derive(Debug)] pub struct Subfield { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: &'static Location<'static>, path_segment: StorePathSegment, inner: Inner, @@ -33,7 +33,7 @@ where { fn clone(&self) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, path_segment: self.path_segment, inner: self.inner.clone(), @@ -56,7 +56,7 @@ impl Subfield { write: fn(&mut Prev) -> &mut T, ) -> Self { Self { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: Location::caller(), inner, path_segment, @@ -119,11 +119,11 @@ where Inner: StoreField, { fn defined_at(&self) -> Option<&'static Location<'static>> { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { Some(self.defined_at) } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { None } diff --git a/router_macro/Cargo.toml b/router_macro/Cargo.toml index 21e3e70fd..674f1ac29 100644 --- a/router_macro/Cargo.toml +++ b/router_macro/Cargo.toml @@ -19,3 +19,6 @@ quote = "1.0" [dev-dependencies] leptos_router = { path = "../router" } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/server_fn/Cargo.toml b/server_fn/Cargo.toml index 519ebe674..40140b91b 100644 --- a/server_fn/Cargo.toml +++ b/server_fn/Cargo.toml @@ -229,3 +229,6 @@ skip_feature_sets = [ "rkyv", ], ] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/tachys/Cargo.toml b/tachys/Cargo.toml index 77708b5b5..41012032c 100644 --- a/tachys/Cargo.toml +++ b/tachys/Cargo.toml @@ -196,3 +196,6 @@ skip_feature_sets = [ "delegation", ], ] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(leptos_debuginfo)'] } \ No newline at end of file diff --git a/tachys/src/html/element/custom.rs b/tachys/src/html/element/custom.rs index 42d618b7a..bfab55ddc 100644 --- a/tachys/src/html/element/custom.rs +++ b/tachys/src/html/element/custom.rs @@ -9,7 +9,7 @@ where E: AsRef, { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), tag: Custom(tag), attributes: (), diff --git a/tachys/src/html/element/elements.rs b/tachys/src/html/element/elements.rs index 166ff1701..f18bb8bea 100644 --- a/tachys/src/html/element/elements.rs +++ b/tachys/src/html/element/elements.rs @@ -25,7 +25,7 @@ macro_rules! html_element_inner { { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), tag: $struct_name, attributes: (), @@ -57,14 +57,14 @@ macro_rules! html_element_inner { ::Output], V>>: Attribute, { let HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, attributes } = self; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, @@ -132,7 +132,7 @@ macro_rules! html_self_closing_elements { { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), attributes: (), children: (), @@ -162,14 +162,14 @@ macro_rules! html_self_closing_elements { ::Output], V>>: Attribute, { let HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, attributes, } = self; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, diff --git a/tachys/src/html/element/mod.rs b/tachys/src/html/element/mod.rs index e1581ca7c..ee249e841 100644 --- a/tachys/src/html/element/mod.rs +++ b/tachys/src/html/element/mod.rs @@ -1,4 +1,4 @@ -#[cfg(debug_assertions)] +#[cfg(any(debug_assertions, leptos_debuginfo))] use crate::hydration::set_currently_hydrating; use crate::{ html::attribute::Attribute, @@ -26,13 +26,13 @@ pub use custom::*; pub use element_ext::*; pub use elements::*; pub use inner_html::*; -#[cfg(debug_assertions)] +#[cfg(any(debug_assertions, leptos_debuginfo))] use std::panic::Location; /// The typed representation of an HTML element. #[derive(Debug, PartialEq, Eq)] pub struct HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] pub(crate) defined_at: &'static Location<'static>, pub(crate) tag: E, pub(crate) attributes: At, @@ -42,7 +42,7 @@ pub struct HtmlElement { impl Clone for HtmlElement { fn clone(&self) -> Self { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, tag: self.tag.clone(), attributes: self.attributes.clone(), @@ -82,14 +82,14 @@ where fn child(self, child: NewChild) -> Self::Output { let HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, attributes, children, } = self; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, attributes, @@ -112,14 +112,14 @@ where attr: NewAttr, ) -> Self::Output { let HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, attributes, children, } = self; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, attributes: attributes.add_any_attr(attr), @@ -242,7 +242,7 @@ where let (attributes, children) = join(self.attributes.resolve(), self.children.resolve()).await; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: self.defined_at, tag: self.tag, attributes, @@ -350,7 +350,7 @@ where cursor: &Cursor, position: &PositionState, ) -> Self::State { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { set_currently_hydrating(Some(self.defined_at)); } diff --git a/tachys/src/hydration.rs b/tachys/src/hydration.rs index 7f7cdd624..94f174972 100644 --- a/tachys/src/hydration.rs +++ b/tachys/src/hydration.rs @@ -2,7 +2,7 @@ use crate::{ renderer::{CastFrom, Rndr}, view::{Position, PositionState}, }; -#[cfg(debug_assertions)] +#[cfg(any(debug_assertions, leptos_debuginfo))] use std::cell::Cell; use std::{cell::RefCell, panic::Location, rc::Rc}; use web_sys::{Comment, Element, Node, Text}; @@ -103,7 +103,7 @@ where } } -#[cfg(debug_assertions)] +#[cfg(any(debug_assertions, leptos_debuginfo))] thread_local! { static CURRENTLY_HYDRATING: Cell>> = const { Cell::new(None) }; } @@ -111,23 +111,23 @@ thread_local! { pub(crate) fn set_currently_hydrating( location: Option<&'static Location<'static>>, ) { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { CURRENTLY_HYDRATING.set(location); } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { _ = location; } } pub(crate) fn failed_to_cast_element(tag_name: &str, node: Node) -> Element { - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { _ = node; unreachable!(); } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { let hydrating = CURRENTLY_HYDRATING .take() @@ -154,12 +154,12 @@ pub(crate) fn failed_to_cast_element(tag_name: &str, node: Node) -> Element { } pub(crate) fn failed_to_cast_marker_node(node: Node) -> Comment { - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { _ = node; unreachable!(); } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { let hydrating = CURRENTLY_HYDRATING .take() @@ -186,12 +186,12 @@ pub(crate) fn failed_to_cast_marker_node(node: Node) -> Comment { } pub(crate) fn failed_to_cast_text_node(node: Node) -> Text { - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { _ = node; unreachable!(); } - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { let hydrating = CURRENTLY_HYDRATING .take() diff --git a/tachys/src/lib.rs b/tachys/src/lib.rs index 15f9fe3b7..d65f82d1a 100644 --- a/tachys/src/lib.rs +++ b/tachys/src/lib.rs @@ -87,7 +87,7 @@ impl UnwrapOrDebug for Result { #[track_caller] fn or_debug(self, el: &Node, name: &'static str) { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { if let Err(err) = self { let location = std::panic::Location::caller(); @@ -101,7 +101,7 @@ impl UnwrapOrDebug for Result { ); } } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { _ = self; } @@ -113,7 +113,7 @@ impl UnwrapOrDebug for Result { el: &Node, name: &'static str, ) -> Option { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] { if let Err(err) = &self { let location = std::panic::Location::caller(); @@ -128,7 +128,7 @@ impl UnwrapOrDebug for Result { } self.ok() } - #[cfg(not(debug_assertions))] + #[cfg(not(any(debug_assertions, leptos_debuginfo)))] { self.ok() } @@ -139,7 +139,7 @@ impl UnwrapOrDebug for Result { #[macro_export] macro_rules! or_debug { ($action:expr, $el:expr, $label:literal) => { - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, leptos_debuginfo)) { $crate::UnwrapOrDebug::or_debug($action, $el, $label); } else { _ = $action; @@ -151,7 +151,7 @@ macro_rules! or_debug { #[macro_export] macro_rules! ok_or_debug { ($action:expr, $el:expr, $label:literal) => { - if cfg!(debug_assertions) { + if cfg!(any(debug_assertions, leptos_debuginfo)) { $crate::UnwrapOrDebug::ok_or_debug($action, $el, $label) } else { $action.ok() diff --git a/tachys/src/mathml/mod.rs b/tachys/src/mathml/mod.rs index 9d4cbc405..a993a22fe 100644 --- a/tachys/src/mathml/mod.rs +++ b/tachys/src/mathml/mod.rs @@ -23,14 +23,14 @@ macro_rules! mathml_global { ::Output], V>>: Attribute, { let HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, attributes } = self; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, @@ -53,7 +53,7 @@ macro_rules! mathml_elements { { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), tag: [<$tag:camel>], attributes: (), @@ -93,14 +93,14 @@ macro_rules! mathml_elements { ::Output], V>>: Attribute, { let HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, attributes } = self; HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at, tag, children, diff --git a/tachys/src/svg/mod.rs b/tachys/src/svg/mod.rs index 12bfc0a79..d1e9a130b 100644 --- a/tachys/src/svg/mod.rs +++ b/tachys/src/svg/mod.rs @@ -19,7 +19,7 @@ macro_rules! svg_elements { where { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), tag: [<$tag:camel>], attributes: (), @@ -49,7 +49,7 @@ macro_rules! svg_elements { ], V>>>::Output: Attribute, { let HtmlElement { tag, children, attributes, - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at } = self; HtmlElement { @@ -57,7 +57,7 @@ macro_rules! svg_elements { children, attributes: attributes.next_tuple($crate::html::attribute::$attr(value)), - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at } } @@ -158,7 +158,7 @@ svg_elements![ pub fn r#use() -> HtmlElement where { HtmlElement { - #[cfg(debug_assertions)] + #[cfg(any(debug_assertions, leptos_debuginfo))] defined_at: std::panic::Location::caller(), tag: Use, attributes: (),