Skip to content

Commit 12c2829

Browse files
committed
Add unsafe when calling a wrapped exported fn
With godot_wrap_method being safe, the generated code to call an exported fn was not wrapped in unsafe anymore. This makes exported `unsafe fn` fail to compile. This commit reintroduces the unsafe scope only when calling the method.
1 parent 8d0e584 commit 12c2829

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

gdnative-core/src/nativescript/macros.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ macro_rules! godot_wrap_method_inner {
117117
) -> $crate::core_types::Variant {
118118
this
119119
.$map_method(|__rust_val, $owner| {
120-
let ret = __rust_val.$method_name(
121-
OwnerArg::from_safe_ref($owner),
122-
$($pname,)*
123-
$($opt_pname,)*
124-
);
125-
OwnedToVariant::owned_to_variant(ret)
120+
#[allow(unused_unsafe)]
121+
unsafe {
122+
let ret = __rust_val.$method_name(
123+
OwnerArg::from_safe_ref($owner),
124+
$($pname,)*
125+
$($opt_pname,)*
126+
);
127+
gdnative::core_types::OwnedToVariant::owned_to_variant(ret)
128+
}
126129
})
127130
.unwrap_or_else(|err| {
128131
$crate::godot_error!("gdnative-core: method call failed with error: {}", err);

0 commit comments

Comments
 (0)