From 92e57fa5be658e4ed18cc3126c645cdc5ae7895d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 23 Mar 2022 18:44:04 +0000 Subject: [PATCH] Don't assume from-var conversion in opaque ret conv When we do a ret-conv of an opaque struct, don't assume that the variable as-parsed exists, instead use the variable that's being created in the ret-conv string if we need to clone. --- gen_type_mapping.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen_type_mapping.py b/gen_type_mapping.py index 0b0e1359..d3d00d28 100644 --- a/gen_type_mapping.py +++ b/gen_type_mapping.py @@ -309,7 +309,7 @@ class TypeMappingGenerator: opaque_ret_conv_suf += "if ((uintptr_t)" + ty_info.var_name + "_var.inner > 4096) {\n" indent = "\t" if not holds_ref and ty_info.is_ptr and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns: # is_ptr, not holds_ref implies passing a pointed-to value to java, which needs copied - opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");\n" + opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&" + ty_info.var_name + "_var);\n" elif not holds_ref and ty_info.is_ptr: opaque_ret_conv_suf += indent + "// WARNING: we may need a move here but no clone is available for " + ty_info.rust_obj + "\n" -- 2.39.5