rust-diplomat / diplomat

Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code
https://rust-diplomat.github.io/book/
Other
480 stars 45 forks source link

Add self-containedness test, fix mutability in C, test clang #515

Closed Manishearth closed 3 weeks ago

Manishearth commented 3 weeks ago

I realized we never started running the self-containedness test (which has the benefit of ensuring all non-tested code still compiles)

Also fixes https://github.com/rust-diplomat/diplomat/issues/516

Manishearth commented 3 weeks ago

GCC is slow so if we do add this to CI it'll probably be added as a new CI job

Manishearth commented 3 weeks ago

@robertbastian I disabled the cpp2 StringsView test for this. I can't see an obvious way to pass slices across; we should have this get handled during attribute validation (or rejected by the backend) and make it something that can be cfg'd on.

[cargo-make] INFO - Running Task: test-cpp2-feature-self-contained
MyString.hpp: In static member function ‘static std::unique_ptr<MyString> MyString::new_from_first(diplomat::span<const std::basic_string_view<char> >)’:
MyString.hpp:60:53: error: cannot convert ‘std::span<const std::basic_string_view<char>, 18446744073709551615>::pointer’ {aka ‘const std::basic_string_view<char>*’} to ‘capi::DiplomatStringsView*’
   60 |   auto result = capi::MyString_new_from_first(v.data(),
      |                                               ~~~~~~^~
      |                                                     |
      |                                                     std::span<const std::basic_string_view<char>, 18446744073709551615>::pointer {aka const std::basic_string_view<char>*}
MyString.hpp:24:60: note:   initializing argument 1 of ‘capi::MyString* capi::MyString_new_from_first(DiplomatStringsView*, size_t)’
   24 |     MyString* MyString_new_from_first(DiplomatStringsView* v_data, size_t v_len);
      |                                       ~~~~~~~~~~~~~~~~~~~~~^~~~~~
Manishearth commented 3 weeks ago

Filed https://github.com/rust-diplomat/diplomat/issues/519 for slice-of-slice