Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert error line buffer to space indentation #6500

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naseschwarz
Copy link

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] #6442

@naseschwarz
Copy link
Author

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 naseschwarz marked this pull request as ready for review March 11, 2025 17:10
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] rust-lang#6442
@naseschwarz naseschwarz force-pushed the fix-hard-tabs-error-reporting-convert-line branch 2 times, most recently from abee1df to ef2726a Compare March 14, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants