File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -698,11 +698,13 @@ fn write_rust_function_shim_impl(
698
698
write ! ( out, "::rust::repr::PtrLen error$ = " ) ;
699
699
}
700
700
write ! ( out, "{}(" , invoke) ;
701
+ let mut needs_comma = false ;
701
702
if sig. receiver . is_some ( ) {
702
703
write ! ( out, "*this" ) ;
704
+ needs_comma = true ;
703
705
}
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 {
706
708
write ! ( out, ", " ) ;
707
709
}
708
710
match & arg. ty {
@@ -725,15 +727,17 @@ fn write_rust_function_shim_impl(
725
727
ty if ty != RustString && out. types . needs_indirect_abi ( ty) => write ! ( out, "$.value" ) ,
726
728
_ => { }
727
729
}
730
+ needs_comma = true ;
728
731
}
729
732
if indirect_return {
730
- if !sig . args . is_empty ( ) {
733
+ if needs_comma {
731
734
write ! ( out, ", " ) ;
732
735
}
733
736
write ! ( out, "&return$.value" ) ;
737
+ needs_comma = true ;
734
738
}
735
739
if indirect_call {
736
- if !sig . args . is_empty ( ) || indirect_return {
740
+ if needs_comma {
737
741
write ! ( out, ", " ) ;
738
742
}
739
743
write ! ( out, "extern$" ) ;
Original file line number Diff line number Diff line change @@ -275,7 +275,7 @@ pub mod ffi {
275
275
fn r_return_r2 ( n : usize ) -> Box < R2 > ;
276
276
fn get ( self : & R2 ) -> usize ;
277
277
fn set ( self : & mut R2 , n : usize ) -> usize ;
278
- fn r_method_on_shared ( self : & Shared ) -> usize ;
278
+ fn r_method_on_shared ( self : & Shared ) -> String ;
279
279
280
280
#[ cxx_name = "rAliasedFunction" ]
281
281
fn r_aliased_function ( x : i32 ) -> String ;
@@ -319,8 +319,8 @@ impl R2 {
319
319
}
320
320
321
321
impl ffi:: Shared {
322
- fn r_method_on_shared ( & self ) -> usize {
323
- 2020
322
+ fn r_method_on_shared ( & self ) -> String {
323
+ " 2020" . to_owned ( )
324
324
}
325
325
}
326
326
Original file line number Diff line number Diff line change @@ -626,7 +626,7 @@ extern "C" const char *cxx_run_test() noexcept {
626
626
ASSERT (r2->get () == 2021 );
627
627
ASSERT (r2->set (2020 ) == 2020 );
628
628
ASSERT (r2->get () == 2020 );
629
- ASSERT (Shared{0 }.r_method_on_shared () == 2020 );
629
+ ASSERT (std::string ( Shared{0 }.r_method_on_shared ()) == " 2020" );
630
630
631
631
ASSERT (std::string (rAliasedFunction (2020 )) == " 2020" );
632
632
You can’t perform that action at this time.
0 commit comments