Skip to content

Commit 7050701

Browse files
bors[bot]setzer22
andauthored
Merge #735
735: Add unsafe when calling a wrapped exported fn r=toasteater a=setzer22 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. Co-authored-by: Setzer22 <jsanchezfsms@gmail.com>
2 parents 8d0e584 + 12c2829 commit 7050701

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)