Skip to content

rustfmt development, versioning, distribution, etc. #4346

Open
@calebcartwright

Description

@calebcartwright

During some recent discussions related to (unreleased) breaking changes in rustfmt, several distinct but related topics and questions were raised. Opening this to both summarize those items and track closure, though imagine some may spin off as separate issues and/or be moved elsewhere.

First, some salient points on the current state:

  • rustfmt is versioned independently of rustc (discussed in Rustfmt stability rfcs#2437)
    • rustfmt v1.4.18 is the most recent version to hit nightly
    • rustfmt v1.4.16 the most recent on stable
  • Updates to rustfmt have to work within two strict constraints:
    • Formatting with default config options must align to the Style Guide which can and does change over time
    • The stability guarantee prevents any style/formatting changes within minor/patch updates (more detail in Stability Guarantee/Version Strategy #4286), so we have to mentally attempt to determine if a given change to rustfmt could impact any formatting in any project, and if so that change has to be rejected or gated/made opt-in
  • Version gating (feature flag of sorts) has been used historically to try to avoid introducing formatting changes, but this often adds a lot of additional code and complexity that complicates maintenance
  • rustfmt is distributed and consumed through multiple channels:
  • rustfmt is a submod in rust-lang/rust
  • rustfmt has a heavy reliance on rustc internals which are consumed via rustc-ap (primarily rustc_ast, rustc_span, and rustc_parse)
  • rustfmt is a dependency of rls which uses rustfmt as a lib
    • rls also depends on racer, which also uses the rustc-ap crates, so addressing breaking rustc-ap changes has to be coordinated across three projects to keep the rustc-ap versions in sync within rust-lang/rust

The default branch in this repo has been the active/primary development branch for 8+ months accumulating unreleased bug fixes, features, and some breaking changes. The published 1.x versions of rustfmt have mostly been in maintenance mode during that window and have only received rustc-ap bumps as necessary and the backporting of fixes for some higher impact bugs.


Questions/topics

Below are some of the topics/questions/feedback from recent discussions, and I'll also add that the decision and outcome for several of these questions could directly impact the others.

  • Should rustfmt continue to be versioned independently from rustc?
  • Should rustfmt continue to be distributed and made consumable from crates.io?
  • Default edition for rustfmt versions should not vary from the distribution they ship with (rustc is still 2015 as of 1.45.0 so rustfmt should be as well)
  • Would the subtree approach work better than the submod approach within rust-lang/rust? (insert issue link here)
    • Big pro is the elimination of the rustc-ap reliance
    • Drawback is the loss of ability to distribute rustfmt via crates.io
  • Should style/formatting changes continue to be considered breaking changes?
  • When do we want to allow breaking changes (style/formatting, or otherwise) to be released?
    • How should breaking changes be shared in advance with the community? (we're working on documenting the current set of unreleased breaking changes already)

Finally, I'll add that one concern I have is that I think it's highly likely we'd end up in a scenario where rustfmt would be violating one or the other core constraints if those both remain in place, and rustfmt is not allowed to ship any new major versions outside of an Edition accompaniment. For example, certain changes to the Style Guide would require an update to default formatting in rustfmt that would in turn break the stability guarantee.

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