-
Notifications
You must be signed in to change notification settings - Fork 776
Description
Edited by @fitzgen
Ever since the switch to quote instead of syntex, the bindings get emitted in a decidedly not-pretty-printed fashion.
We have an option to run rustfmt on the bindings: --rustfmt-bindings/Builder::rustfmt_bindings. It is off by default, but it should be on by default. Instead, users should turn it off if they don't need it or want it.
See src/options.rs and src/lib.rs for the command line flags and Builder definition respectively.
Original comment:
Bindgen could really do with sticking in some more newlines.
Eg at the moment I'm getting this 4000 character monstrosity, which I reckon should be about a hundred lines of code.
This is a recent regression. I assume, but have not verified, that it's a result of merging no-syntex.
Perhaps the intention is that I should always manually rustfmt the output? That does give an OK-ish solution - rustfmt does a pretty good job with the line that I linked above, though it fails later in the file with lines that are too long for it.
If the intention is that rustfmt is the solution then the docs should say something about this. Eg the README example doggo.h actually gives output that's not much like what is promised:
/* automatically generated by rust-bindgen */
# [ repr ( C ) ] # [ derive ( Debug , Copy ) ] pub struct Doggo { pub many : :: std :: os :: raw :: c_int , pub wow : :: std :: os :: raw :: c_char , } # [ test ] fn bindgen_test_layout_Doggo ( ) { assert_eq ! ( :: std :: mem :: size_of :: < Doggo > ( ) , 8usize , concat ! ( "Size of: " , stringify ! ( Doggo ) ) ) ; assert_eq ! ( :: std :: mem :: align_of :: < Doggo > ( ) , 4usize , concat ! ( "Alignment of " , stringify ! ( Doggo ) ) ) ; assert_eq ! ( unsafe { & ( * ( 0 as * const Doggo ) ) . many as * const _ as usize } , 0usize , concat ! ( "Alignment of field: " , stringify ! ( Doggo ) , "::" , stringify ! ( many ) ) ) ; assert_eq ! ( unsafe { & ( * ( 0 as * const Doggo ) ) . wow as * const _ as usize } , 4usize , concat ! ( "Alignment of field: " , stringify ! ( Doggo ) , "::" , stringify ! ( wow ) ) ) ; } impl Clone for Doggo { fn clone ( & self ) -> Self { * self } } extern "C" {
pub fn eleven_out_of_ten_majestic_af ( pupper : * mut Doggo , ) ;