Skip to content

Commit 2850baa

Browse files
committed
Print ref conversion in write_(from|to)_c_conversion_to_ref_prefix
Not idea why this was not true originally, but clearly when writing a *reference* conversion, we should be doing so as a *reference*.
1 parent a86b1d7 commit 2850baa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

c-bindings-gen/src/types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,28 +2483,28 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
24832483
// Note that compared to the above conversion functions, the following two are generally
24842484
// significantly undertested:
24852485
pub fn write_from_c_conversion_to_ref_prefix<W: std::io::Write>(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>) {
2486-
self.write_conversion_inline_intern(w, t, generics, false, false, false, "() /*", true, |_, _| "&local_".to_owned(),
2486+
self.write_conversion_inline_intern(w, t, generics, true, false, false, "() /*", true, |_, _| "&local_".to_owned(),
24872487
|a, b, _c| {
24882488
if let Some(conv) = self.from_c_conversion_prefix_from_path(a, b) {
24892489
Some(format!("&{}", conv))
24902490
} else { None }
24912491
},
2492-
|w, decl_type, _full_path, is_ref, _is_mut, _is_trait_alias| match decl_type {
2493-
DeclType::StructImported {..} if !is_ref => write!(w, "").unwrap(),
2492+
|w, decl_type, _full_path, _is_ref, _is_mut, _is_trait_alias| match decl_type {
2493+
DeclType::StructImported {..} => write!(w, "").unwrap(),
24942494
_ => unimplemented!(),
24952495
});
24962496
}
24972497
pub fn write_from_c_conversion_to_ref_suffix<W: std::io::Write>(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>) {
2498-
self.write_conversion_inline_intern(w, t, generics, false, false, false, "*/", false,
2498+
self.write_conversion_inline_intern(w, t, generics, true, false, false, "*/", false,
24992499
|has_inner, map_str_opt| match (has_inner, map_str_opt) {
25002500
(false, Some(map_str)) => format!(".iter(){}.collect::<Vec<_>>()[..]", map_str),
25012501
(false, None) => ".iter().collect::<Vec<_>>()[..]".to_owned(),
25022502
(true, None) => "[..]".to_owned(),
25032503
(true, Some(_)) => unreachable!(),
25042504
},
25052505
|a, b, _c| self.from_c_conversion_suffix_from_path(a, b),
2506-
|w, decl_type, _full_path, is_ref, _is_mut, _is_trait_alias| match decl_type {
2507-
DeclType::StructImported {..} if !is_ref => write!(w, ".get_native_ref()").unwrap(),
2506+
|w, decl_type, _full_path, _is_ref, _is_mut, _is_trait_alias| match decl_type {
2507+
DeclType::StructImported {..} => write!(w, ".get_native_ref()").unwrap(),
25082508
_ => unimplemented!(),
25092509
});
25102510
}

0 commit comments

Comments
 (0)