Skip to content

Commit 74608d7

Browse files
committed
Add test of indirect return on member function
cxxbridge/sources/tests/ffi/lib.rs.cc: In member function ‘rust::cxxbridge05::String tests::Shared::r_method_on_shared() const’: cxxbridge/sources/tests/ffi/lib.rs.cc:1583:52: error: no match for ‘operator&’ (operand types are ‘const tests::Shared’ and ‘rust::cxxbridge05::String’) 1583 | tests$cxxbridge05$Shared$r_method_on_shared(*this&return$.value); | ~~~~~^~~~~~~~~~~~~~ | | | | | rust::cxxbridge05::String | const tests::Shared
1 parent 22f5ff7 commit 74608d7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/ffi/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub mod ffi {
274274
fn r_return_r2(n: usize) -> Box<R2>;
275275
fn get(self: &R2) -> usize;
276276
fn set(self: &mut R2, n: usize) -> usize;
277-
fn r_method_on_shared(self: &Shared) -> usize;
277+
fn r_method_on_shared(self: &Shared) -> String;
278278

279279
#[cxx_name = "rAliasedFunction"]
280280
fn r_aliased_function(x: i32) -> String;
@@ -318,8 +318,8 @@ impl R2 {
318318
}
319319

320320
impl ffi::Shared {
321-
fn r_method_on_shared(&self) -> usize {
322-
2020
321+
fn r_method_on_shared(&self) -> String {
322+
"2020".to_owned()
323323
}
324324
}
325325

tests/ffi/tests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ extern "C" const char *cxx_run_test() noexcept {
626626
ASSERT(r2->get() == 2021);
627627
ASSERT(r2->set(2020) == 2020);
628628
ASSERT(r2->get() == 2020);
629-
ASSERT(Shared{0}.r_method_on_shared() == 2020);
629+
ASSERT(std::string(Shared{0}.r_method_on_shared()) == "2020");
630630

631631
ASSERT(std::string(rAliasedFunction(2020)) == "2020");
632632

0 commit comments

Comments
 (0)