This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit ec24833
authored
Rollup merge of rust-lang#68845 - dwrensha:fix-68783, r=estebank
stop using BytePos for computing spans in librustc_parse/parser/mod.rs
Computing spans using logic such as `self.token.span.lo() + BytePos(1)` can cause internal compiler errors like rust-lang#68730 when non-ascii characters are given as input.
rust-lang#68735 partially addressed this problem, but only for one case. Moreover, its usage of `next_point()` does not actually align with what `bump_with()` expects. For example, given the token `>>=`, we should pass the span consisting of the final two characters `>=`, but `next_point()` advances the span beyond the end of the `=`.
This pull request instead computes the start of the new span by doing `start_point(self.token.span).hi()`. This matches `self.token.span.lo() + BytePos(1)` in the common case where the characters are ascii, and it gracefully handles multibyte characters.
Fixes rust-lang#68783.File tree
2 files changed
+22
-17
lines changed- src
- librustc_parse/parser
- test/ui/parser
2 files changed
+22
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
618 | | - | |
619 | | - | |
| 618 | + | |
| 619 | + | |
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
637 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
638 | 639 | | |
639 | 640 | | |
640 | 641 | | |
| |||
650 | 651 | | |
651 | 652 | | |
652 | 653 | | |
653 | | - | |
654 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
| |||
671 | 673 | | |
672 | 674 | | |
673 | 675 | | |
674 | | - | |
675 | | - | |
| 676 | + | |
| 677 | + | |
676 | 678 | | |
677 | 679 | | |
678 | 680 | | |
679 | | - | |
680 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
681 | 686 | | |
682 | 687 | | |
683 | 688 | | |
| |||
707 | 712 | | |
708 | 713 | | |
709 | 714 | | |
710 | | - | |
711 | | - | |
| 715 | + | |
| 716 | + | |
712 | 717 | | |
713 | 718 | | |
714 | | - | |
715 | | - | |
| 719 | + | |
| 720 | + | |
716 | 721 | | |
717 | 722 | | |
718 | | - | |
719 | | - | |
| 723 | + | |
| 724 | + | |
720 | 725 | | |
721 | 726 | | |
722 | 727 | | |
| |||
Binary file not shown.
0 commit comments