rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Convert error line buffer to space indentation

Open naseschwarz opened this issue 8 months ago • 1 comments

The type of indentation is not important for error reporting. However, keeping the indentation as tabs has two issues:

  1. 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].
  2. 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

naseschwarz avatar Mar 11 '25 16:03 naseschwarz

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.

naseschwarz avatar Mar 11 '25 17:03 naseschwarz