Describe the bug
Whenever custom types (e.g., structs) are used in a Rust circuit, there is a possibility that the Rust compiler will reorder fields in these types when producing the circuit IR. When assigner is later called on the IR, it will fail because the order of fields in the public inputs file does not match the order of fields in the IR. There are two solutions to this: reorder fields in the IR manually or use the #[repr(C)] directive before a struct. Both solutions are not so great in terms of dev exp.
Describe the bug Whenever custom types (e.g., structs) are used in a Rust circuit, there is a possibility that the Rust compiler will reorder fields in these types when producing the circuit IR. When
assigner
is later called on the IR, it will fail because the order of fields in the public inputs file does not match the order of fields in the IR. There are two solutions to this: reorder fields in the IR manually or use the#[repr(C)]
directive before a struct. Both solutions are not so great in terms of dev exp.To Reproduce Use
cargo
to compile this circuit:Then call
assigner
with this inputs file.Expected behavior The compiler does NOT reorder fields in structs when producing an IR.
Toolchain versions
rustc 1.73.0-nightly (a516bc539 2023-12-14) (zkLLVM 0.1.18)
0.1.18