mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.75k stars 228 forks source link

Allow `include_scaffolding!` macro to work with `#![deny(missing_docs)]` enabled #1502

Open tnull opened 1 year ago

tnull commented 1 year ago

I'd like to be able to enforce documentation for every exposed object and method in my crate, i.e., enable #![deny(missing_docs)].

However, this unfortunately doesn't play together with the uniffi::include_scaffolding! macro, as the generated code doesn't add documentation:

...

note: the lint level is defined here
  --> src/lib.rs:62:9
   |
62 | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for a function
  --> /Users/ero/workspace/ldk-node/target/debug/build/ldk-node-787dae1c6d9c96d5/out/ldk_node.uniffi.rs:63:1
   |
63 | pub unsafe extern "C" fn ffi_ldk_node_4a35_rustbuffer_reserve(buf: uniffi::RustBuffer, additional: i32, call_status: &mut uniffi::RustCallStatus) -> uniffi::RustBuffe...
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: missing documentation for a macro
    --> /Users/ero/workspace/ldk-node/target/debug/build/ldk-node-787dae1c6d9c96d5/out/ldk_node.uniffi.rs:1230:1
     |
1230 | macro_rules! uniffi_reexport_scaffolding {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...

I'm aware of https://github.com/mozilla/uniffi-rs/issues/1476, however the workaround suggested there doesn't work for me, as I define my types in a submodule which needs to access UniffiCustomTypeConverter. If I apply said workaround, UniffiCustomTypeConverter can't be found as it's private and therefore must be included in the crate root to be used by submodules.

┆Issue is synchronized with this Jira Task ┆Issue Number: UNIFFI-247

badboy commented 1 year ago

Still not a perfect solution, but if you use the solution from #1476 and also move the impl UniffiCustomTypeConverter into that mod ffi it should work.

tnull commented 1 year ago

Still not a perfect solution, but if you use the solution from #1476 and also move the impl UniffiCustomTypeConverter into that mod ffi it should work.

No, this is unfortunately not a solution at all. I won't arbitrary relocate type definitions just to make this lint work or fix Uniffi generation behavior for that matter.

badboy commented 1 year ago

Still not a perfect solution, but if you use the solution from #1476 and also move the impl UniffiCustomTypeConverter into that mod ffi it should work.

No, this is unfortunately not a solution at all. I won't arbitrary relocate type definitions just to make this lint work or fix Uniffi generation behavior for that matter.

As I said a solution, a workaround, not a perfect one. If you can think of a proper way we can handle that your input (or PR) would be welcome.