Skip to content

Commit b4335d2

Browse files
committed
Handle -> () as an fn return value
1 parent de7d5a4 commit b4335d2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

c-bindings-gen/src/blocks.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,14 +593,19 @@ pub fn write_method_params<W: std::io::Write>(w: &mut W, sig: &syn::Signature, t
593593
write!(w, ")").unwrap();
594594
match &sig.output {
595595
syn::ReturnType::Type(_, rtype) => {
596-
write!(w, " -> ").unwrap();
597-
if let Some(mut remaining_path) = first_seg_self(&*rtype) {
598-
if remaining_path.next().is_none() {
599-
write!(w, "{}", this_param).unwrap();
600-
return;
596+
let mut ret_ty = Vec::new();
597+
types.write_c_type(&mut ret_ty, &*rtype, generics, true);
598+
599+
if !ret_ty.is_empty() {
600+
write!(w, " -> ").unwrap();
601+
if let Some(mut remaining_path) = first_seg_self(&*rtype) {
602+
if remaining_path.next().is_none() {
603+
write!(w, "{}", this_param).unwrap();
604+
return;
605+
}
601606
}
607+
w.write_all(&ret_ty).unwrap();
602608
}
603-
types.write_c_type(w, &*rtype, generics, true);
604609
},
605610
_ => {},
606611
}

0 commit comments

Comments
 (0)