Skip to content

Commit 84b4a56

Browse files
committed
Use explicit calls in a few more places to avoid recursion limits
1 parent aabfdd5 commit 84b4a56

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

c-bindings-gen/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
850850
writeln_arg_docs(w, &$field.attrs, "", types, Some(&gen_types), vec![].drain(..), Some(&ref_type));
851851
write!(w, "#[no_mangle]\npub extern \"C\" fn {}_get_{}(this_ptr: &{}) -> ", struct_name, $new_name, struct_name).unwrap();
852852
types.write_c_type(w, &ref_type, Some(&gen_types), true);
853-
write!(w, " {{\n\tlet mut inner_val = &mut this_ptr.get_native_mut_ref().{};\n\t", $real_name).unwrap();
853+
write!(w, " {{\n\tlet mut inner_val = &mut {}::get_native_mut_ref(this_ptr).{};\n\t", struct_name, $real_name).unwrap();
854854
let local_var = types.write_to_c_conversion_from_ownable_ref_new_var(w, &format_ident!("inner_val"), &ref_type, Some(&gen_types));
855855
if local_var { write!(w, "\n\t").unwrap(); }
856856
types.write_to_c_conversion_inline_prefix(w, &ref_type, Some(&gen_types), true);
@@ -867,7 +867,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
867867
writeln_arg_docs(w, &$field.attrs, "", types, Some(&gen_types), vec![].drain(..), Some(&$field.ty));
868868
writeln!(w, "///\n/// Returns a copy of the field.").unwrap();
869869
write!(w, "#[no_mangle]\npub extern \"C\" fn {}_get_{}(this_ptr: &{}) -> {}", struct_name, $new_name, struct_name, s).unwrap();
870-
write!(w, " {{\n\tlet mut inner_val = this_ptr.get_native_mut_ref().{}.clone();\n\t", $real_name).unwrap();
870+
write!(w, " {{\n\tlet mut inner_val = {}::get_native_mut_ref(this_ptr).{}.clone();\n\t", struct_name, $real_name).unwrap();
871871
let local_var = types.write_to_c_conversion_new_var(w, &format_ident!("inner_val"), &$field.ty, Some(&gen_types), true);
872872
if local_var { write!(w, "\n\t").unwrap(); }
873873
types.write_to_c_conversion_inline_prefix(w, &$field.ty, Some(&gen_types), true);
@@ -1454,18 +1454,18 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
14541454
writeln!(w, "\tfn clone(&self) -> Self {{").unwrap();
14551455
writeln!(w, "\t\tSelf {{").unwrap();
14561456
writeln!(w, "\t\t\tinner: if <*mut native{}>::is_null(self.inner) {{ core::ptr::null_mut() }} else {{", ident).unwrap();
1457-
writeln!(w, "\t\t\t\tObjOps::heap_alloc(unsafe {{ &*ObjOps::untweak_ptr(self.inner) }}.clone()) }},").unwrap();
1457+
writeln!(w, "\t\t\t\tObjOps::heap_alloc(Clone::clone(unsafe {{ &*ObjOps::untweak_ptr(self.inner) }})) }},").unwrap();
14581458
writeln!(w, "\t\t\tis_owned: true,").unwrap();
14591459
writeln!(w, "\t\t}}\n\t}}\n}}").unwrap();
14601460
writeln!(w, "#[allow(unused)]").unwrap();
14611461
writeln!(w, "/// Used only if an object of this type is returned as a trait impl by a method").unwrap();
14621462
writeln!(w, "pub(crate) extern \"C\" fn {}_clone_void(this_ptr: *const c_void) -> *mut c_void {{", ident).unwrap();
1463-
writeln!(w, "\tBox::into_raw(Box::new(unsafe {{ (*(this_ptr as *const native{})).clone() }})) as *mut c_void", ident).unwrap();
1463+
writeln!(w, "\tBox::into_raw(Box::new(Clone::clone(unsafe {{ &*(this_ptr as *const native{}) }}))) as *mut c_void", ident).unwrap();
14641464
writeln!(w, "}}").unwrap();
14651465
writeln!(w, "#[no_mangle]").unwrap();
14661466
writeln!(w, "/// Creates a copy of the {}", ident).unwrap();
14671467
writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{", ident, ident, ident).unwrap();
1468-
writeln!(w, "\torig.clone()").unwrap();
1468+
writeln!(w, "\tClone::clone(orig)").unwrap();
14691469
writeln!(w, "}}").unwrap();
14701470
} else if path_matches_nongeneric(&trait_path.1, &["FromStr"]) {
14711471
let mut err_opt = None;

0 commit comments

Comments
 (0)