corrupt code is generated if the union contains an array.
Input C/C++ Header
//test.h
union TestUnion {
int testArray[ 5 ] ;
} ;
Bindgen Invocation
bindgen test.h --no-derive-copy --no-derive-debug --no-layout-tests
Actual Results
/* automatically generated by rust-bindgen */
#[repr(C)]; 5usize ] , }
Expected Results
#[repr(C)]
pub union TestUnion {
pub testArray : [ ::std::os::raw::c_int ; 5 ] ,
}
Environment
OS/distribution
ArchLinux
bindgen version
bindgen --version bindgen 0.31.3
rustc version
rustc --version rustc 1.23.0-nightly (d6b06c63a 2017-11-09)
clang version
clang --version clang version 5.0.0 (tags/RELEASE_500/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin
and also clang39 get same result.
Description
First of all, I'm sorry if my English is hard to understand.
If the union contains an array, bindgen generate strange code fragment like above. I use "--no-derive-copy --no-derive-debug --no-layout-tests" flags here to reduce the code for explanation. Even without them, I get the same corrupt code fragment. And I also tried "--rust-target=nightly" flag but it does not take effect.
I think this is a rustfmt bug, and using --no-rustfmt-bindings or upgrading / using rustfmt-nightly should work, see #1045 and similar issues.
Thanks for the report!