Join GitHub today
Implement proof of concept for formatting specific line ranges #959
This series of commits adds a proof of concept of restricting formatting to specific line ranges, controlled by the
The goal is to make incremental formatting possible, and allow improving the formatting of a codebase one change at a time. This is much better than requiring that an entire project be formatted in one go in order to get the benefits of rustfmt. In later commits, we can add a tool to format a project based on a diff which will allow adding rustfmt to, eg, a git pre-commit hook without risk of introducing unrelated changes across a codebase.
There is some heuristic work needed to follow on from this to enable incremental formatting of all AST node types. For some, we will want to format when a change overlaps the AST node; for others, only when the change fully contains the AST node. As an example, we won't want to reformat an entire function because one line in it changed, but we would want to reformat an entire function signature if part of it changed. This will be done in later commits.
Outline of the commits in the series:
You've probably figured by now (#795, #801, #871) that I'm not super happy with the way
The change here is sort of a stop-gap to prevent making the situation worse. If there's no compatibility guarantee for v1.0 and
@nrc, no worries. I've been away for a bit myself.
Re this PR, I would like to get it reviewed as is, and merged with whatever changes come out of that review. I want to get the basic infrastructure hammered out and merged in before going too far into further work on it.
I'm replying to a few of the earlier comment threads.