Running rustfmt on rust-lang/rust and other rust-lang repositories

use_small_heuristics = "Max" is confirmed to work great on my code and reduce churn.

Here are some stats from formatting changes:
use_small_heuristics = "Default"

src/librustc_privacy/lib.rs                 |  574 ++++--
src/librustc_resolve/build_reduced_graph.rs |  576 ++++--
src/librustc_resolve/check_unused.rs        |   65 +-
src/librustc_resolve/error_reporting.rs     |   46 +-
src/librustc_resolve/lib.rs                 | 2756 ++++++++++++++++-----------
src/librustc_resolve/macros.rs              |  646 +++++--
src/librustc_resolve/resolve_imports.rs     | 1008 ++++++----

use_small_heuristics = "Max"

src/librustc_privacy/lib.rs                 |  466 ++---
src/librustc_resolve/build_reduced_graph.rs |  463 +++--
src/librustc_resolve/check_unused.rs        |   55 +-
src/librustc_resolve/error_reporting.rs     |   23 +-
src/librustc_resolve/lib.rs                 | 2426 +++++++++++++++------------
src/librustc_resolve/macros.rs              |  555 +++---
src/librustc_resolve/resolve_imports.rs     |  913 ++++++----

The remaining churn is mostly the switch from visual indentation to block indentation, which is okay and expected, and is indeed a consensus of the style RFC process.

4 Likes

The only notable exception not fixed by use_small_heuristics = "Max" is if-else at the end of the block, but it looks like a fix was in progress, but is stuck now.

Haha, personally Iā€™m still wishing that 2-space indentation had won out over 4-space indentation in the early days, as IMO all Rust code looks 1000x better that way. Too late now, of course! Iā€™m content knowing that rustfmt.toml is a thing for my own personal projects, at least. :smile:

I strongly disagree with the suggestions I sometimes hear about how rustfmt should not be configurable at all and that something like the gofmt approach is more desirable. No thanks! Caring about how code is formatted to that extent is just a bit much I think.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.