Description
rustfmt is currently a submodule in this repository, but there's been ongoing discussion and experimentation for a while now to investigate the possibility of switching rustfmt to a subtree in a similar vein as #70651 (additional background/motivation at the bottom of the issue description)
Thanks to @jyn514, the bulk of the changes that would be needed for this conversion have been identified (e.g. #82208), but there's a number of items in my mind that would still need to be resolved/answered before we could proceed. Opening this issue to facilitate those discussions separately from the PR given the quantity of folks that would get notified there.
A non-exhuastive list of questions/steps that I think would need to be discussed before converting:
rust-side
- would
x.py fmt
continue to use an older/pinned nightly or use the rustfmt version in tree? - would any additional CI checks be necessary or helpful? For example within the rust-lang/rustfmt repo our CI has some functional-like tests that run the updated rustfmt version against different repositories (it's very easy to make seemingly innocuous changes in rustfmt that result in different formatting being emitted)
- any updates needed to the rustc dev guide? For example I'd imagine the submod section in the conributing intro should be updated prior to the conversion or at least very shortly after
hooking into high-five config to notify rustfmt team (or at least @calebcartwright) on changes to src/tools/rustfmt(done Notify myself on rustfmt updates highfive#311)
rustfmt-side
- change default branch (current default branch in rust-lang/rustfmt is set to a previously planned but subsequently indefinitely postponed 2.0 version of rustfmt for reasons I won't go into here)
- I don't have access to change this currently
- update documentation for contributors
- CI review/updates (we currently have a job that runs with the beta toolchain)
general thoughts/questions
- switching rustfmt to a subtree will add overhead to compiler contributors. is this acceptable?
- will PRs that modify rustfmt in rust-lang/rust (outside fixes/adjustments required due to rustc mod changes) be rejected? E.g. if someone opens a PR here to add a new config option
- I assume this is the case but want to be explicit about it, as changes to rustfmt made in rust-lang/rust that bypassed the rustfmt team would be rather problematic IMO
- how easily would we be able to revert back to a submodule should the need arise?
- what should the sync frequency be? 2 weeks?
- I need to educate myself on the process for sync, if conflicts are possible/how best to resolve, etc.
background/motivation
rustfmt is heavily reliant on internal rustc mods (particularly rustc_parse, rustc_ast, and rustc_span) and this is unlikely to change for the foreseeable future. rustfmt currently consumes these via the auto publish crates which ends up being the root cause of several challenges (many discussed in #82208), notably the frequent and often extended broken toolstate on nightly.
The thinking is that switching to a subtree would greatly reduce the toolstate issues and associated fallout. Additionally, the other benefit in leveraging the knowledge and expertise of the compiler contributors to apply rustc mod changes in the rustfmt codebase is that it would help the rustfmt development process, since the rustfmt team would no longer have to retroactively apply large batches of rustc mod changes themselves.
It's worth noting that rustfmt is also published to crates.io (though admittedly not for a long time, as I don't have access to that either). Switching rustfmt to a subtree would of course result in no longer being able to publish rustfmt directly to crates.io, however, we would still have the option of utilizing and extending the existing rustc auto publish process to continue publishing rustfmt to crates.io just like the other rustc mods