Rust: Disagreement between x.py tidy and rustfmt

Created on 12 Jul 2020  路  5Comments  路  Source: rust-lang/rust

https://github.com/rust-lang/rust/blob/9d09331e00b02f81c714b0c41ce3a38380dd36a2/src/libstd/io/buffered.rs#L1136-L1140

rustfmt and x.py fmt disagree about the correct formatting of this block. This causes issues with editors configured to "rustfmt-on-save", because you have to keep manually reverting / running tidy. You can see this in the commit log for #72808, which has many commits that unintentionally / accidentally bounce between the two formats:

https://github.com/rust-lang/rust/pull/72808/commits/1bf8ba3546aace5a16852d5f58fd9206934cc829
https://github.com/rust-lang/rust/pull/72808/commits/e89e2e42f9269fe401b1eef0288ff12c7941544f
https://github.com/rust-lang/rust/pull/72808/commits/8df5ae0fffc9de2884e0c916bdcd74cb69949b1c
https://github.com/rust-lang/rust/pull/72808/commits/f7650fe3f955863e810ef7816edbe78f88393d87

A-contributor-roadblock A-rustbuild

Most helpful comment

Isn't this somewhat expected (if unfortunate) as ./x.py fmt is pinned to a specific version of rustfmt and rustfmt has
some slightly changes between different versions?

All 5 comments

Isn't this somewhat expected (if unfortunate) as ./x.py fmt is pinned to a specific version of rustfmt and rustfmt has
some slightly changes between different versions?

Specifically see

https://github.com/rust-lang/rust/blob/9d09331e00b02f81c714b0c41ce3a38380dd36a2/src/stage0.txt#L19-L23

Unfortunately it's pinned to a specific nightly rather than using the previous stable like rustc/cargo do, so using something like a rust-toolchain file to pick the toolchain and integrate with rustup wouldn't fix this problem.

This has now been documented in https://github.com/rust-lang/rustc-dev-guide/pull/883. @Lucretiel do you think that's good enough to close the issue?

I'll give it a try and see if it fixes

Yes, that's fixed it, thank you!

Was this page helpful?
0 / 5 - 0 ratings