Skip to content

Commit 5029f71

Browse files
authored
Merge pull request #1449 from godot-rust/bugfix/cfg-function-param
Avoid `#[cfg]` in fn param -> generated `#[doc(cfg(...))]` invalid
2 parents c5fe799 + 9b9d64b commit 5029f71

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

godot-core/src/builtin/callable.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,21 @@ impl Callable {
313313
R: ToGodot,
314314
S: Into<CowStr>,
315315
{
316-
Self::from_fn_wrapper_with_thread(
317-
name,
318-
rust_function,
319-
linked_object_id,
320-
#[cfg(safeguards_balanced)]
321-
Some(std::thread::current().id()),
322-
)
316+
let thread_id = if cfg!(safeguards_balanced) {
317+
Some(std::thread::current().id())
318+
} else {
319+
None // Thread not checked.
320+
};
321+
322+
Self::from_fn_wrapper_with_thread(name, rust_function, linked_object_id, thread_id)
323323
}
324324

325325
fn from_fn_wrapper_with_thread<F, R, S>(
326326
name: S,
327327
rust_function: F,
328328
linked_object_id: Option<InstanceId>,
329-
#[cfg(safeguards_balanced)] thread_id: Option<std::thread::ThreadId>,
329+
// No #[cfg] on param; would be converted to (invalid) #[doc(cfg)].
330+
_thread_id: Option<std::thread::ThreadId>,
330331
) -> Self
331332
where
332333
F: FnMut(&[&Variant]) -> R,
@@ -340,7 +341,7 @@ impl Callable {
340341
name,
341342
name_cached: OnceLock::new(),
342343
#[cfg(safeguards_balanced)]
343-
thread_id,
344+
thread_id: _thread_id,
344345
linked_object_id,
345346
};
346347

0 commit comments

Comments
 (0)