Commit 80476f3
committed
Fix panic in annotated_snippet dependency (#4968).
* Internally, rustfmt preserves tabs and counts them as multiple
characters (based on configuration).
* The annotated_snippet dependency always counts tabs as 1 character.
* If rustfmt tries to display an error on a line containing tabs,
the indicies are mismatched.
* In the extreme case, annotated_snippet may try to access out-of-range
indices, and panic.
* This change is based on the code review by camsteffen on PR #5039 by
karyon: have rustfmt internally replace tabs with the corresponding
number of spaces, so that columns/indices in the buffer passed to
annotated_snippet are counted (unambiguously and) the same.1 parent 0439486 commit 80476f3
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
| 592 | + | |
| 593 | + | |
592 | 594 | | |
593 | 595 | | |
594 | | - | |
| 596 | + | |
| 597 | + | |
595 | 598 | | |
596 | 599 | | |
597 | | - | |
598 | 600 | | |
599 | 601 | | |
600 | 602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments