Closed dj8yfo closed 1 year ago
While resolving #110 , the following snippet fails to compile (in the BorshSerialize part). It must be more or less obvious bug, as derive of BorshDeserialize succeeds (as well as BorshSerialize for tuple struct variants).
BorshSerialize
BorshDeserialize
use borsh::{self, BorshSerialize, BorshDeserialize}; #[derive(BorshDeserialize)] enum AA { B { #[borsh_skip] c: i32, d: u32, }, NegatedVariant { beta: u8, } } #[derive(BorshDeserialize)] enum AAT { B(#[borsh_skip] i32, u32), NegatedVariant { beta: u8, } } #[derive(BorshSerialize)] enum AATB { B(#[borsh_skip] i32, u32), NegatedVariant { beta: u8, } } #[derive(BorshSerialize)] enum AATTB { B(#[borsh_skip] i32, #[borsh_skip] u32), NegatedVariant { beta: u8, } } // ERROR! #[derive(BorshSerialize)] enum AB { B { #[borsh_skip] c: i32, d: u32, }, NegatedVariant { beta: String, } } // ERROR! #[derive(BorshSerialize)] enum AAB { B { #[borsh_skip] c: i32, #[borsh_skip] d: u32, }, NegatedVariant { beta: String, } } fn main() { }
1 error: expected field pattern, found `_` --> src/main.rs:44:10 2 error: expected `}`, found `c` --> src/main.rs:48:9 3 error: proc-macro derive produced unparsable tokens --> src/main.rs:44:10 4 error: expected field pattern, found `_` --> src/main.rs:58:10 5 error: expected `}`, found `c` --> src/main.rs:62:9 6 error: proc-macro derive produced unparsable tokens --> src/main.rs:58:10 7 error[E0425]: cannot find value `d` in this scope --> src/main.rs:50:9
https://github.com/dj8yfo/struct_variant_field_borsh_skip_derive_fail - this is a crate, identical to snippet in header
While resolving #110 , the following snippet fails to compile (in the
BorshSerialize
part). It must be more or less obvious bug, as derive ofBorshDeserialize
succeeds (as well asBorshSerialize
for tuple struct variants).