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
532 stars 51 forks source link

`enum`s where variants have contents should throw an error during lowering #732

Closed emarteca closed 1 week ago

emarteca commented 1 week ago

Diplomat doesn't support enums where the variants have contents. E.g.:

enum MyEnum {
    A(i32), // not supported
    B,
}

Right now, there is no error thrown during lowering, if some of the variants have contents. This is confusing, because then the generated code doesn't support the Rust type in the block. But potentially more importantly, this causes errors on 32-bit architecture, as the size of the enum differs in the generated C vs. what exists on the Rust side.


I think the fix would be to throw an error during lowering if the enum has a variant with contents.