From 9b9d64b11b20d4cdccae941bbcac3d452fbfb4df Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Tue, 23 Dec 2025 17:18:13 +0100 Subject: [PATCH] Avoid `#[cfg]` in fn param -> generated `#[doc(cfg(...))]` invalid --- godot-core/src/builtin/callable.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/godot-core/src/builtin/callable.rs b/godot-core/src/builtin/callable.rs index 4cc7e2830..4b73e0b25 100644 --- a/godot-core/src/builtin/callable.rs +++ b/godot-core/src/builtin/callable.rs @@ -313,20 +313,21 @@ impl Callable { R: ToGodot, S: Into, { - Self::from_fn_wrapper_with_thread( - name, - rust_function, - linked_object_id, - #[cfg(safeguards_balanced)] - Some(std::thread::current().id()), - ) + let thread_id = if cfg!(safeguards_balanced) { + Some(std::thread::current().id()) + } else { + None // Thread not checked. + }; + + Self::from_fn_wrapper_with_thread(name, rust_function, linked_object_id, thread_id) } fn from_fn_wrapper_with_thread( name: S, rust_function: F, linked_object_id: Option, - #[cfg(safeguards_balanced)] thread_id: Option, + // No #[cfg] on param; would be converted to (invalid) #[doc(cfg)]. + _thread_id: Option, ) -> Self where F: FnMut(&[&Variant]) -> R, @@ -340,7 +341,7 @@ impl Callable { name, name_cached: OnceLock::new(), #[cfg(safeguards_balanced)] - thread_id, + thread_id: _thread_id, linked_object_id, };