rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

bindgen-cli generates mixed EOL if rustfmt is configured to use non-native style

Open ZyX-II opened this issue 5 months ago • 0 comments

The following script run on Windows will generate file header.rs which has first four lines ending with CRLF and rest ending with LF:

cd %~dp0

echo int foo; > header.h
echo newline_style = "Unix" > fmt.toml

bindgen "header.h" ^
    -o header.rs ^
    --raw-line "pub use std;" ^
    --rustfmt-configuration-file %~dp0\fmt.toml

I assume this is because rustfmt configuration is not applied to raw-line (third line), bindgen own comment (first line) and empty lines separating comment from raw lines and raw lines from the rest of the file.

I also assume that on linux same problem can be reproduced if rustfmt was configured to use CRLF instead.

Bindgen version: 0.72.0.

ZyX-II avatar Jul 03 '25 17:07 ZyX-II