Skip to content

Commit 9d84036

Browse files
committed
Fix placement of commas in C++ member functions that call Rust methods
1 parent 74608d7 commit 9d84036

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

gen/src/write.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,13 @@ fn write_rust_function_shim_impl(
698698
write!(out, "::rust::repr::PtrLen error$ = ");
699699
}
700700
write!(out, "{}(", invoke);
701+
let mut needs_comma = false;
701702
if sig.receiver.is_some() {
702703
write!(out, "*this");
704+
needs_comma = true;
703705
}
704-
for (i, arg) in sig.args.iter().enumerate() {
705-
if i > 0 || sig.receiver.is_some() {
706+
for arg in &sig.args {
707+
if needs_comma {
706708
write!(out, ", ");
707709
}
708710
match &arg.ty {
@@ -725,15 +727,17 @@ fn write_rust_function_shim_impl(
725727
ty if ty != RustString && out.types.needs_indirect_abi(ty) => write!(out, "$.value"),
726728
_ => {}
727729
}
730+
needs_comma = true;
728731
}
729732
if indirect_return {
730-
if !sig.args.is_empty() {
733+
if needs_comma {
731734
write!(out, ", ");
732735
}
733736
write!(out, "&return$.value");
737+
needs_comma = true;
734738
}
735739
if indirect_call {
736-
if !sig.args.is_empty() || indirect_return {
740+
if needs_comma {
737741
write!(out, ", ");
738742
}
739743
write!(out, "extern$");

0 commit comments

Comments
 (0)