use ManuallyDrop in ptrcalls to prevent drop reordering
@@ -468,8 +468,12 @@ mod ptrcall {
.map(|(name, ty)| generate_argument_pre(ty, name));
let return_pre = generate_return_pre(&sig.return_type);
+ let arg_forgets = arguments.clone().map(|(name, _)| {
+ quote! { let #name = ::std::mem::ManuallyDrop::new(#name); }
+ });
+
let arg_drops = arguments.clone().map(|(name, _)| {
- quote! { drop(#name); }
+ quote! { ::std::mem::ManuallyDrop::into_inner(#name); }
});
quote! {
@@ -479,6 +483,8 @@ mod ptrcall {
#(#args),*
];
+ #(#arg_forgets)*
+
#return_pre
(gd_api.godot_method_bind_ptrcall)(method_bind, obj_ptr, argument_buffer.as_mut_ptr() as *mut _, ret_ptr as *mut _);
