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

replace `cargo fmt` with the `prettyplease` crate

Open yoshuawuyts opened this issue 2 years ago • 0 comments

In order to more structurally work around code formatting issues like those described in https://github.com/bytecodealliance/wit-bindgen/pull/878, we should consider switching from cargo fmt to Dtolnay's prettyplease crate. This crate was designed specifically to format codegen; meaning it will format faster, fail less frequently, but may occasionally result in subtly different formatting than what cargo fmt would have come up with.

I've used this succesfully in my http-bindgen crate, and I believe this might work better for wit-bindgen too. In practice I've yet to experience any divergent code formatting output. If we're worried about this becoming an issue however, we could always add a #![rustfmt::skip] attribute to the top of our generated files. Thanks!

yoshuawuyts avatar Mar 04 '24 16:03 yoshuawuyts