mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2025-02-17 06:57:37 +00:00
Add regression test for issue 738
Currently fails to build. In file included from cxx-test-suite-32b8d00ca9482f5f/out/cxxbridge/crate/tests/ffi/tests.h:2, from tests.cc:1: cxx-test-suite-32b8d00ca9482f5f/out/cxxbridge/include/rust/cxx.h: In instantiation of ‘Ret rust::cxxbridge1::Fn<Ret(Args ...)>::operator()(Args ...) const [with Ret = void; Args = {rust::cxxbridge1::String&}]’: tests.cc:504:18: required from here cxx-test-suite-32b8d00ca9482f5f/out/cxxbridge/include/rust/cxx.h:478:29: error: cannot bind non-const lvalue reference of type ‘rust::cxxbridge1::String&’ to an rvalue of type ‘std::remove_reference<rust::cxxbridge1::String&>::type’ {aka ‘rust::cxxbridge1::String’} 478 | return (*this->trampoline)(std::move(args)..., this->fn); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cxx-test-suite-32b8d00ca9482f5f/out/cxxbridge/include/rust/cxx.h:478:58: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 478 | return (*this->trampoline)(std::move(args)..., this->fn); | ^
This commit is contained in:
parent
ffa979bd18
commit
6e2223bf79
@ -157,6 +157,8 @@ pub mod ffi {
|
||||
fn c_take_ref_rust_vec_copy(v: &Vec<u8>);
|
||||
fn c_take_ref_shared_string(s: &SharedString) -> &SharedString;
|
||||
fn c_take_callback(callback: fn(String) -> usize);
|
||||
fn c_take_callback_ref(callback: fn(&String));
|
||||
fn c_take_callback_mut(callback: fn(&mut String));
|
||||
fn c_take_enum(e: Enum);
|
||||
fn c_take_ns_enum(e: AEnum);
|
||||
fn c_take_nested_ns_enum(e: ABEnum);
|
||||
|
@ -494,6 +494,16 @@ void c_take_callback(rust::Fn<size_t(rust::String)> callback) {
|
||||
callback("2020");
|
||||
}
|
||||
|
||||
void c_take_callback_ref(rust::Fn<void(const rust::String &)> callback) {
|
||||
const rust::String string = "2020";
|
||||
callback(string);
|
||||
}
|
||||
|
||||
void c_take_callback_mut(rust::Fn<void(rust::String &)> callback) {
|
||||
rust::String string = "2020";
|
||||
callback(string);
|
||||
}
|
||||
|
||||
void c_take_enum(Enum e) {
|
||||
if (e == Enum::AVal) {
|
||||
cxx_test_suite_set_correct();
|
||||
|
@ -160,6 +160,8 @@ void c_take_ref_rust_vec_index(const rust::Vec<uint8_t> &v);
|
||||
void c_take_ref_rust_vec_copy(const rust::Vec<uint8_t> &v);
|
||||
const SharedString &c_take_ref_shared_string(const SharedString &s);
|
||||
void c_take_callback(rust::Fn<size_t(rust::String)> callback);
|
||||
void c_take_callback_ref(rust::Fn<void(const rust::String &)> callback);
|
||||
void c_take_callback_mut(rust::Fn<void(rust::String &)> callback);
|
||||
void c_take_enum(Enum e);
|
||||
void c_take_ns_enum(::A::AEnum e);
|
||||
void c_take_nested_ns_enum(::A::B::ABEnum e);
|
||||
|
@ -204,7 +204,21 @@ fn test_c_callback() {
|
||||
0
|
||||
}
|
||||
|
||||
fn callback_ref(s: &String) {
|
||||
if s == "2020" {
|
||||
cxx_test_suite_set_correct();
|
||||
}
|
||||
}
|
||||
|
||||
fn callback_mut(s: &mut String) {
|
||||
if s == "2020" {
|
||||
cxx_test_suite_set_correct();
|
||||
}
|
||||
}
|
||||
|
||||
check!(ffi::c_take_callback(callback));
|
||||
check!(ffi::c_take_callback_ref(callback_ref));
|
||||
check!(ffi::c_take_callback_mut(callback_mut));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user