uniffi-rs
uniffi-rs copied to clipboard
Non-exhaustive enums seem to trouble uniffi
Repro from branch in https://github.com/contentauth/c2pa-python/pull/82 (clone, checkout the branch, run `cargo build).
In our code,
impl Signer for RemoteSignerhas a function,alg, that returns aSigningAlgenum.- The enum is defined in a dependency,
c2pa-rs. In there,SigningAlgis a non exhaustive enum: https://github.com/contentauth/c2pa-rs/blob/main/internal/crypto/src/raw_signature/signing_alg.rs#L31
It seems this troubles uniffi, as the build fails:
Compiling c2pa-python v0.6.2 (/git/@CAI/c2pa-python)
error[E0004]: non-exhaustive patterns: `_` not covered
--> /git/@CAI/c2pa-python/target/debug/build/c2pa-python-3be618cc7bdb8e16/out/c2pa.uniffi.rs:115:1
|
115 | #[::uniffi::udl_derive(Enum)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `_` not covered
|
note: `SigningAlg` defined here
--> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2pa-crypto-0.3.0/src/raw_signature/signing_alg.rs:32:1
|
32 | pub enum SigningAlg {
| ^^^^^^^^^^^^^^^^^^^
= note: the matched value is of type `SigningAlg`
= note: `SigningAlg` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively
= note: this error originates in the attribute macro `::uniffi::udl_derive` (in Nightly builds, run with -Z macro-backtrace for more info)
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
115 | #[::uniffi::udl_derive(Enum)], _ => todo!()
| ++++++++++++++
For more information about this error, try `rustc --explain E0004`.