Skip to content

Commit ceb7776

Browse files
authored
Merge pull request #1058 from godot-rust/bugfix/compile-time-validations
Move some compile-time validations from godot to godot-ffi
2 parents 5b09d29 + 62059bb commit ceb7776

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

godot-ffi/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@
1616
1717
#![cfg_attr(test, allow(unused))]
1818

19+
// ----------------------------------------------------------------------------------------------------------------------------------------------
20+
// Validations
21+
22+
// More validations in godot crate. #[cfg]s are checked in godot-core.
23+
24+
#[cfg(all(feature = "codegen-lazy-fptrs", feature = "experimental-threads"))]
25+
compile_error!(
26+
"Cannot combine `lazy-function-tables` and `experimental-threads` features;\n\
27+
thread safety for lazy-loaded function pointers is not yet implemented."
28+
);
29+
30+
#[cfg(all(
31+
feature = "experimental-wasm-nothreads",
32+
feature = "experimental-threads"
33+
))]
34+
compile_error!("Cannot use 'experimental-threads' with a nothreads Wasm build yet.");
35+
36+
// ----------------------------------------------------------------------------------------------------------------------------------------------
37+
1938
// Output of generated code. Mimics the file structure, symbols are re-exported.
2039
#[rustfmt::skip]
2140
#[allow(

godot/src/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,19 @@ pub mod __docs;
143143
// ----------------------------------------------------------------------------------------------------------------------------------------------
144144
// Validations
145145

146-
#[cfg(all(feature = "lazy-function-tables", feature = "experimental-threads"))]
147-
compile_error!("Thread safety for lazy function pointers is not yet implemented.");
148-
149-
#[cfg(all(
150-
feature = "experimental-wasm-nothreads",
151-
feature = "experimental-threads"
152-
))]
153-
compile_error!("Cannot use 'experimental-threads' with a nothreads Wasm build yet.");
146+
// Many validations are moved to godot-ffi. #[cfg]s are not emitted in this crate, so move checks for those up to godot-core.
154147

155148
#[cfg(all(target_family = "wasm", not(feature = "experimental-wasm")))]
156-
compile_error!("Must opt-in using `experimental-wasm` Cargo feature; keep in mind that this is work in progress");
149+
compile_error!(
150+
"Wasm target requires opt-in via `experimental-wasm` Cargo feature;\n\
151+
keep in mind that this is work in progress."
152+
);
157153

158154
// See also https://github.com/godotengine/godot/issues/86346.
155+
// Could technically be moved to godot-codegen to reduce time-to-failure slightly, but would scatter validations even more.
159156
#[cfg(all(feature = "double-precision", not(feature = "api-custom")))]
160157
compile_error!("The feature `double-precision` currently requires `api-custom` due to incompatibilities in the GDExtension API JSON.");
161158

162-
// Note: #[cfg]s are not emitted in this crate, so move checks for those up to godot-core.
163-
164159
// ----------------------------------------------------------------------------------------------------------------------------------------------
165160
// Modules
166161

0 commit comments

Comments
 (0)