Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion godot-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ api-custom = ["godot-bindings/api-custom"]
api-custom-json = ["godot-bindings/api-custom-json"]
experimental-godot-api = []
experimental-threads = []
experimental-required-objs = []

[dependencies]
godot-bindings = { path = "../godot-bindings", version = "=0.4.2" }
Expand Down
2 changes: 1 addition & 1 deletion godot-codegen/src/conv/type_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn to_rust_type_uncached(full_ty: &GodotTy, ctx: &mut Context) -> RustTy {
arg_passing: ctx.get_builtin_arg_passing(full_ty),
}
} else {
let is_nullable = if cfg!(feature = "experimental-required-objs") {
let is_nullable = if cfg!(since_api = "4.6") {
full_ty.meta.as_ref().is_none_or(|m| m != "required")
} else {
true
Expand Down
11 changes: 0 additions & 11 deletions godot-codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ pub const IS_CODEGEN_FULL: bool = false;
#[cfg(feature = "codegen-full")]
pub const IS_CODEGEN_FULL: bool = true;

#[cfg(all(feature = "experimental-required-objs", before_api = "4.6"))]
fn __feature_warning() {
// Not a hard error, it's experimental anyway and allows more flexibility like this.
#[must_use = "The `experimental-required-objs` feature needs at least Godot 4.6-dev version"]
fn feature_has_no_effect() -> i32 {
1
}

feature_has_no_effect();
}

fn write_file(path: &Path, contents: String) {
let dir = path.parent().unwrap();
let _ = std::fs::create_dir_all(dir);
Expand Down
1 change: 0 additions & 1 deletion godot-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ codegen-lazy-fptrs = [
double-precision = ["godot-codegen/double-precision"]
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
experimental-threads = ["godot-ffi/experimental-threads", "godot-codegen/experimental-threads"]
experimental-required-objs = ["godot-codegen/experimental-required-objs"]
experimental-wasm-nothreads = ["godot-ffi/experimental-wasm-nothreads"]
debug-log = ["godot-ffi/debug-log"]
trace = []
Expand Down
30 changes: 30 additions & 0 deletions godot-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,33 @@ pub mod private;
/// Re-export logging macro.
#[doc(hidden)]
pub use godot_ffi::out;

// ----------------------------------------------------------------------------------------------------------------------------------------------

/// Tests for code that must not compile.
///
/// To add a new one, simply add a new `__*` named function with a `compile_fail` doc attribute.
mod no_compile_tests {
/// With Godot 4.6+, functions with required parameters accept `Gd<T>` instead of `Option<Gd<T>>`.
///
/// ```compile_fail
/// use godot::prelude::*;
/// let mut node: Gd<Node> = unimplemented!();
/// let option = Some(node.clone());
/// let option: Option<&Gd<Node>> = option.as_ref();
///
/// // Following must not compile since `add_child` accepts only required (non-null) arguments.
/// node.add_child(option);
/// ```
///
/// Sanity check that without the last line, it _does_ compile. This catches any regressions in the previous statements that would not
/// be caught by the above `compile_fail` test.
/// ```no_run
/// use godot::prelude::*;
/// let mut node: Gd<Node> = unimplemented!();
/// let option = Some(node.clone());
/// let option: Option<&Gd<Node>> = option.as_ref();
/// ```
#[cfg(since_api = "4.6")]
fn __required_param_must_not_take_option() {}
}
1 change: 0 additions & 1 deletion godot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ custom-json = ["api-custom-json"]
double-precision = ["godot-core/double-precision"]
experimental-godot-api = ["godot-core/experimental-godot-api"]
experimental-threads = ["godot-core/experimental-threads"]
experimental-required-objs = ["godot-core/experimental-required-objs"]
experimental-wasm = []
experimental-wasm-nothreads = ["godot-core/experimental-wasm-nothreads"]
codegen-rustfmt = ["godot-core/codegen-rustfmt"]
Expand Down
22 changes: 0 additions & 22 deletions godot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@
//! Access to `godot::classes` APIs that Godot marks "experimental". These are under heavy development and may change at any time.
//! If you opt in to this feature, expect breaking changes at compile and runtime.<br><br>
//!
//! * **`experimental-required-objs`**
//!
//! Enables _required_ objects in Godot function signatures. When GDExtension advertises parameters or return value as required (non-null), the
//! generated code will use `Gd<T>` instead of `Option<Gd<T>>` for type safety. This will undergo many breaking changes as the API evolves;
//! we are explicitly excluding this from any SemVer guarantees. Needs Godot 4.6-dev. See <https://github.com/godot-rust/gdext/pull/1383>.
//!
//! _Rust functionality toggles:_
//!
//! * **`lazy-function-tables`**
Expand Down Expand Up @@ -279,19 +273,3 @@ pub use godot_core::private;

/// Often-imported symbols.
pub mod prelude;

/// Tests for code that must not compile.
// Do not add #[cfg(test)], it seems to break `cargo test -p godot --features godot/api-custom,godot/experimental-required-objs`.
mod no_compile_tests {
/// ```compile_fail
/// use godot::prelude::*;
/// let mut node: Gd<Node> = todo!();
/// let option = Some(node.clone());
/// let option: Option<&Gd<Node>> = option.as_ref();
///
/// // Following must not compile since `add_child` accepts only required (non-null) arguments. Comment-out for sanity check.
/// node.add_child(option);
/// ```
#[cfg(feature = "experimental-required-objs")]
fn __test_invalid_patterns() {}
}
2 changes: 1 addition & 1 deletion itest/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib"]
# Default feature MUST be empty for workflow reasons, even if it differs from the default feature set in upstream `godot` crate.
default = []
codegen-full = ["godot/__codegen-full"]
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api", "godot/experimental-required-objs"]
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api"]
experimental-threads = ["godot/experimental-threads"]
register-docs = ["godot/register-docs"]
serde = ["dep:serde", "dep:serde_json", "godot/serde"]
Expand Down
6 changes: 2 additions & 4 deletions itest/rust/src/engine_tests/node_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ fn node_call_group(ctx: &TestContext) {
assert!(!node.has_meta("something"));
}

// Experimental required parameter/return value.
/* TODO(v0.5): enable once https://github.com/godot-rust/gdext/pull/1383 is merged.
#[cfg(all(feature = "codegen-full-experimental", since_api = "4.6"))]
// Required parameter/return value.
#[cfg(all(feature = "codegen-full", since_api = "4.6"))]
#[itest]
fn node_required_param_return() {
use godot::classes::Tween;
Expand All @@ -97,4 +96,3 @@ fn node_required_param_return() {

parent.free();
}
*/
Loading