Skip to content

Gradual formatting settings changes via existing vs desired config sections. #5584

@dpc

Description

@dpc

I really wish Rust had is a standardized solution to gradually introducing/changing formatting. In a larger project changing formatting settings always involve either a very undesirable huge patch changing formatting over the whole project, or some shenanigans around avoiding it.

I had an idea how gradual formatting changes with rustfmt could be achieved that I posted on reddit and no one pointed out how is it infeasible, so I thought I'll post it here as well:

Maybe rustfmt could maintain "existing" and "desired" sections in "rustfmt.toml" and if an existing file (or even better: a piece of code) matches "existing" formatting settings just leave it as is when formatting, while parts that are not correctly formatted w.r.t "existing" format would get formatted using "desired" settings. cargo fmt --check would accept code formatted with any of the two styles.

I hope that this would be relatively easy to implement (thought might be wrong), and it seems to me it would work well in practice and allow project to gradually roll out formatting changes, and also allow Rust style team to evolve things without introducing continuous churn.

If something like this already exists or was proposed, please let me know and feel free to close this issue. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions