Skip to content

Commit 7b8f4e4

Browse files
authored
Merge pull request #1416 from godot-rust/qol/required-ptr-general-availability
Remove `experimental-required-objs` Cargo feature
2 parents 6f85b4d + 3b8494c commit 7b8f4e4

File tree

9 files changed

+34
-42
lines changed

9 files changed

+34
-42
lines changed

godot-codegen/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ api-custom = ["godot-bindings/api-custom"]
2020
api-custom-json = ["godot-bindings/api-custom-json"]
2121
experimental-godot-api = []
2222
experimental-threads = []
23-
experimental-required-objs = []
2423

2524
[dependencies]
2625
godot-bindings = { path = "../godot-bindings", version = "=0.4.2" }

godot-codegen/src/conv/type_conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn to_rust_type_uncached(full_ty: &GodotTy, ctx: &mut Context) -> RustTy {
251251
arg_passing: ctx.get_builtin_arg_passing(full_ty),
252252
}
253253
} else {
254-
let is_nullable = if cfg!(feature = "experimental-required-objs") {
254+
let is_nullable = if cfg!(since_api = "4.6") {
255255
full_ty.meta.as_ref().is_none_or(|m| m != "required")
256256
} else {
257257
true

godot-codegen/src/lib.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ pub const IS_CODEGEN_FULL: bool = false;
5151
#[cfg(feature = "codegen-full")]
5252
pub const IS_CODEGEN_FULL: bool = true;
5353

54-
#[cfg(all(feature = "experimental-required-objs", before_api = "4.6"))]
55-
fn __feature_warning() {
56-
// Not a hard error, it's experimental anyway and allows more flexibility like this.
57-
#[must_use = "The `experimental-required-objs` feature needs at least Godot 4.6-dev version"]
58-
fn feature_has_no_effect() -> i32 {
59-
1
60-
}
61-
62-
feature_has_no_effect();
63-
}
64-
6554
fn write_file(path: &Path, contents: String) {
6655
let dir = path.parent().unwrap();
6756
let _ = std::fs::create_dir_all(dir);

godot-core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ codegen-lazy-fptrs = [
2222
double-precision = ["godot-codegen/double-precision"]
2323
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
2424
experimental-threads = ["godot-ffi/experimental-threads", "godot-codegen/experimental-threads"]
25-
experimental-required-objs = ["godot-codegen/experimental-required-objs"]
2625
experimental-wasm-nothreads = ["godot-ffi/experimental-wasm-nothreads"]
2726
debug-log = ["godot-ffi/debug-log"]
2827
trace = []

godot-core/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,33 @@ pub mod private;
7272
/// Re-export logging macro.
7373
#[doc(hidden)]
7474
pub use godot_ffi::out;
75+
76+
// ----------------------------------------------------------------------------------------------------------------------------------------------
77+
78+
/// Tests for code that must not compile.
79+
///
80+
/// To add a new one, simply add a new `__*` named function with a `compile_fail` doc attribute.
81+
mod no_compile_tests {
82+
/// With Godot 4.6+, functions with required parameters accept `Gd<T>` instead of `Option<Gd<T>>`.
83+
///
84+
/// ```compile_fail
85+
/// use godot::prelude::*;
86+
/// let mut node: Gd<Node> = unimplemented!();
87+
/// let option = Some(node.clone());
88+
/// let option: Option<&Gd<Node>> = option.as_ref();
89+
///
90+
/// // Following must not compile since `add_child` accepts only required (non-null) arguments.
91+
/// node.add_child(option);
92+
/// ```
93+
///
94+
/// Sanity check that without the last line, it _does_ compile. This catches any regressions in the previous statements that would not
95+
/// be caught by the above `compile_fail` test.
96+
/// ```no_run
97+
/// use godot::prelude::*;
98+
/// let mut node: Gd<Node> = unimplemented!();
99+
/// let option = Some(node.clone());
100+
/// let option: Option<&Gd<Node>> = option.as_ref();
101+
/// ```
102+
#[cfg(since_api = "4.6")]
103+
fn __required_param_must_not_take_option() {}
104+
}

godot/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ custom-json = ["api-custom-json"]
1919
double-precision = ["godot-core/double-precision"]
2020
experimental-godot-api = ["godot-core/experimental-godot-api"]
2121
experimental-threads = ["godot-core/experimental-threads"]
22-
experimental-required-objs = ["godot-core/experimental-required-objs"]
2322
experimental-wasm = []
2423
experimental-wasm-nothreads = ["godot-core/experimental-wasm-nothreads"]
2524
codegen-rustfmt = ["godot-core/codegen-rustfmt"]

godot/src/lib.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@
131131
//! Access to `godot::classes` APIs that Godot marks "experimental". These are under heavy development and may change at any time.
132132
//! If you opt in to this feature, expect breaking changes at compile and runtime.<br><br>
133133
//!
134-
//! * **`experimental-required-objs`**
135-
//!
136-
//! Enables _required_ objects in Godot function signatures. When GDExtension advertises parameters or return value as required (non-null), the
137-
//! generated code will use `Gd<T>` instead of `Option<Gd<T>>` for type safety. This will undergo many breaking changes as the API evolves;
138-
//! we are explicitly excluding this from any SemVer guarantees. Needs Godot 4.6-dev. See <https://github.com/godot-rust/gdext/pull/1383>.
139-
//!
140134
//! _Rust functionality toggles:_
141135
//!
142136
//! * **`lazy-function-tables`**
@@ -279,19 +273,3 @@ pub use godot_core::private;
279273

280274
/// Often-imported symbols.
281275
pub mod prelude;
282-
283-
/// Tests for code that must not compile.
284-
// Do not add #[cfg(test)], it seems to break `cargo test -p godot --features godot/api-custom,godot/experimental-required-objs`.
285-
mod no_compile_tests {
286-
/// ```compile_fail
287-
/// use godot::prelude::*;
288-
/// let mut node: Gd<Node> = todo!();
289-
/// let option = Some(node.clone());
290-
/// let option: Option<&Gd<Node>> = option.as_ref();
291-
///
292-
/// // Following must not compile since `add_child` accepts only required (non-null) arguments. Comment-out for sanity check.
293-
/// node.add_child(option);
294-
/// ```
295-
#[cfg(feature = "experimental-required-objs")]
296-
fn __test_invalid_patterns() {}
297-
}

itest/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ crate-type = ["cdylib"]
1313
# Default feature MUST be empty for workflow reasons, even if it differs from the default feature set in upstream `godot` crate.
1414
default = []
1515
codegen-full = ["godot/__codegen-full"]
16-
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api", "godot/experimental-required-objs"]
16+
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api"]
1717
experimental-threads = ["godot/experimental-threads"]
1818
register-docs = ["godot/register-docs"]
1919
serde = ["dep:serde", "dep:serde_json", "godot/serde"]

itest/rust/src/engine_tests/node_test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ fn node_call_group(ctx: &TestContext) {
7575
assert!(!node.has_meta("something"));
7676
}
7777

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

9897
parent.free();
9998
}
100-
*/

0 commit comments

Comments
 (0)