My experience/timeline trying to submit a fix for a panic (crash) in rustfmt that frequently triggered on my code
Genuinely, I don't mean to pile on or blame the maintainers; as we should all know, it's volunteer work and they've already done an amazing job on limited bandwidth. However, in the conversation of "users complain but don't contribute", I think my experience is clear evidence/validation for the sentiment "why try to contribute if it won't be looked at". On top of that, near the end of 2023, something about the toolchain changed that made running a locally built rustfmt with your own fixes particularly difficult (maybe it's easier again), so that's especially discouraging for potential contributors
In my use case, this crash was triggered by a combination of the settings hard_tabs, max_width, error_on_unformatted, and error_on_line_overflow. Most files don't trigger it, but in a sufficiently large code base, it happens quite frequently. When rustfmt crashes, the input file is understandably but still quite inconveniently left unformatted
- 2021 August: #4968 filed; a discrepancy in how characters and columns are counted means a logical indexing error resulting in a panic in the dependency used to format/pretty-print code annotated with diagnostics.
- 2021 October: #5039 PR submitted by another user. The diff is just 1 line and a test case.
- 2022 February: a reviewer makes a few minor suggestions to the fix. There's no follow-up by the person who submitted the PR.
- 2022 December: I submit #5629 that's just the #5039 with the reviewer's suggestions. The diff is +4/-2 and a test case. I refer, summarize, and give credit to the people and discussion in #4968 and #5039.
- The same day, a maintainer comments on it, and asks if I can investigate 4/5 potentially related issues/comments.
- The next day, I give a detailed reply and follow up on each of the semi-related issues. I don't hear back.
- Locally, I use a locally built rustfmt since without a fix, it frequently crashes on my code.
- 2023 June 19: I ask in Zulip (rustfmt channel - not sure if I'm allowed to post direct links) "Request to look at a PR?". Maintainers are understandably busy; I thank them for the update and say I'll keep an eye on things.
- (Fuzzy) Around the end of 2023, some stuff changed that made it quite hard to use a locally built rustfmt. It's a PITA but I get some hack working.
- 2024 March 18: I ask again "Request for review of old PR?" since I'm still repeatedly running into this crash on my code. I'm told that there's a related fix in #6084 submitted in 2024 February; it appears that the panic can also be triggered by mismatching byte/char indices. I didn't check if this PR fixes the issue with tabs, since if I need to use a local hack anyways, my current fix is sufficient for myself.
- 2024 November: related(?) PR #6391 is submitted.
- 2025 January: #6391 is accepted. I haven't checked if that fixes the tab issue since I stopped working in rust.
I'll admit/if it wasn't already obvious that I'm a bit salty at the whole process, especially because I had a somewhat similar experience trying to submit a library PR with some almost trivial constification changes that I actually needed/would have used in my own code. However, if you read my PR and comments in Zulip, I think I've been nothing but friendly to and understanding of the maintainers.
Here's what I said in my 2023 June 19 zulip post:
Hello! Would it be possible to request a look at #5629? It's been around for a while but I'll try to summarize:
(omitted for brevity)
and
Thanks for the detailed update! I totally understand that there are other priorities/limited bandwidth - I know there have been frustrations (e.g. I saw the reddit thread from a few weeks ago), but I do appreciate the work you guys put in and many others do too! In any case, I'll keep an eye out for feedback :)
In 2024 March:
Any chance https://github.com/rust-lang/rustfmt/pull/5629 could be looked at? I hit the crash pretty often in my own project with comments or macros. I used to be able to build my own branch from source (I know it's not recommended), but since the toolchain was updated to
nightly-2023-12-28, building/installing from source doesn't work for meI know bandwidth is pretty tight (thanks for the overall upkeep!), but even a rough idea of whether it'll be looked at (or workarounds) would be appreciated. Thanks again!
and
Great, thanks for the update!