rustfmt
rustfmt copied to clipboard
Convert error line buffer to space indentation
The type of indentation is not important for error reporting. However, keeping the indentation as tabs has two issues:
- rustfmt keeps track of widths, not character offsets. For space indentation, these two are the same. For tab indentation, this leads to issues like [1].
- annotate-snippet-rs always format leading tabs as four spaces. Thus, formatter error reporting is not faithful and ranges will not be marked correctly (or need another transformation).
Replacing tabs with spaces for error reporting as early as possible solves these issues.
[1] https://github.com/rust-lang/rustfmt/issues/6442
Originally, I was planning to add a test to this. However, it seems like there's no test facility that is related to this that does error reporting, which I would need to check? Any guidance would be appreciated - thanks.