frol/flatc-rust

Error while compiling the generated code: the trait Default is not implemented for [u8; 40]

XX opened this issue · 4 comments

XX commented
error[E0277]: the trait bound `[u8; 40]: Default` is not satisfied
   --> cluster/protofiles/src/struct_generated.rs:707:23
    |
707 | pub struct COrderLink(pub [u8; 40]);
    |                       ^^^^^^^^^^^^ the trait `Default` is not implemented for `[u8; 40]`
    |
    = help: the following implementations were found:
              <&[T] as Default>
              <&mut [T] as Default>
              <[T; 0] as Default>
              <[T; 10] as Default>
            and 31 others
    = note: required by `std::default::Default::default`
    = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
XX commented

Fixed this by replacing the struct to table.

frol commented

Rust implements Default only for arrays of the length of up to 32 elements (using macros producing the impls for every single length of the arrays). Once Const Generics land, this limitation will be removed. There is nothing we can do here at flatc-rust level.

XX commented

@frol It looks like the flatc is generating non-compileable code. The old version works well.

frol commented

@XX Please, report the code-generation issue to the flatc upstream. This crate is just a simple wrapper.