Commit 939e4c9
committed
Guard against overflow in
Make `span_to_lines` to return a `Result`.
(This is better than just asserting internally, since it allows caller
to decide if they can recover from the problem.)
Added type alias for `FileLinesResult` returned by `span_to_lines`.
Update embedded unit test to reflect `span_to_lines` signature change.
In diagnostic, catch `Err` from `span_to_lines` and print
`"(internal compiler error: unprintable span)"` instead.
----
There a number of recent issues that report the bug here. See
e.g. #24761 and #24954.
This change *might* fix them. However, that is not its main goal.
The main goals are:
1. Make it possible for callers to recover from an error here, and
2. Insert a more conservative check, in that we are
also checking that the files match up.codemap::span_to_lines.1 parent 42cb2de commit 939e4c9
2 files changed
+45
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
670 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
671 | 675 | | |
672 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
673 | 686 | | |
674 | 687 | | |
675 | 688 | | |
| |||
693 | 706 | | |
694 | 707 | | |
695 | 708 | | |
696 | | - | |
| 709 | + | |
697 | 710 | | |
698 | 711 | | |
699 | 712 | | |
| |||
918 | 931 | | |
919 | 932 | | |
920 | 933 | | |
921 | | - | |
| 934 | + | |
922 | 935 | | |
923 | 936 | | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
924 | 945 | | |
925 | 946 | | |
926 | 947 | | |
| |||
1086 | 1107 | | |
1087 | 1108 | | |
1088 | 1109 | | |
1089 | | - | |
| 1110 | + | |
1090 | 1111 | | |
1091 | 1112 | | |
1092 | 1113 | | |
| |||
1131 | 1152 | | |
1132 | 1153 | | |
1133 | 1154 | | |
1134 | | - | |
| 1155 | + | |
1135 | 1156 | | |
1136 | 1157 | | |
1137 | 1158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
| 525 | + | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | | - | |
| 570 | + | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
573 | 581 | | |
574 | 582 | | |
575 | 583 | | |
| |||
690 | 698 | | |
691 | 699 | | |
692 | 700 | | |
693 | | - | |
| 701 | + | |
694 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
695 | 711 | | |
696 | 712 | | |
697 | 713 | | |
| |||
0 commit comments