cxx
cxx copied to clipboard
Improve error message on signatures containing self by value
The current error is shown as:
error[cxxbridge]: unsupported signature
┌─ /dev/stdin:1:54
│
1 │ #[cxx::bridge] mod ffi { extern "C++" { type T; fn f(self); }}
│ ^^^^ unsupported signature
Instead it should say what to use instead. &self
or &mut self
for shared structs and opaque Rust types, self: Pin<&mut Self>
for an opaque C++ type, Box<T>
or UniquePtr<T>
if ownership needs to be transferred depending on opaque Rust or opaque C++ type.
Regarding an improved error message...it doesn't seem like Box<T>
receivers are supported currently? Did you intend to mention something else for the "if ownership needs to be transferred" case, or maybe there was an implied "use Box/UniquePtr but not as a method receiver" there?
Yeah it would need to be a nonmember function where Box<T> or UniquePtr<T> is the argument type (as opposed to receiver).