Add test of cxx_name which is Rust keyword

Currently fails with:

    error[cxxbridge]: expected identifier
       ┌─ lib.rs:46:22
       │
    46 │         #[cxx_name = "type"]
       │                      ^^^^^^ expected identifier
This commit is contained in:
David Tolnay 2023-01-07 12:02:00 -08:00
parent 13e7e10414
commit 7d7c757e28
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 7 additions and 4 deletions

View File

@ -43,6 +43,7 @@ pub mod ffi {
#[namespace = "A"]
#[derive(Copy, Clone, Default)]
struct AShared {
#[cxx_name = "type"]
z: usize,
}

View File

@ -86,7 +86,9 @@ std::unique_ptr<::H::H> c_return_ns_unique_ptr() {
const size_t &c_return_ref(const Shared &shared) { return shared.z; }
const size_t &c_return_ns_ref(const ::A::AShared &shared) { return shared.z; }
const size_t &c_return_ns_ref(const ::A::AShared &shared) {
return shared.type;
}
const size_t &c_return_nested_ns_ref(const ::A::B::ABShared &shared) {
return shared.z;
@ -240,7 +242,7 @@ void c_take_shared(Shared shared) {
}
void c_take_ns_shared(::A::AShared shared) {
if (shared.z == 2020) {
if (shared.type == 2020) {
cxx_test_suite_set_correct();
}
}
@ -397,7 +399,7 @@ void c_take_rust_vec_shared(rust::Vec<Shared> v) {
void c_take_rust_vec_ns_shared(rust::Vec<::A::AShared> v) {
uint32_t sum = 0;
for (auto i : v) {
sum += i.z;
sum += i.type;
}
if (sum == 2021) {
cxx_test_suite_set_correct();
@ -916,7 +918,7 @@ void ns_c_take_trivial(::tests::D d) {
}
void ns_c_take_ns_shared(::A::AShared shared) {
if (shared.z == 2020) {
if (shared.type == 2020) {
cxx_test_suite_set_correct();
}
}