Skip to content

Avoid invalid spans in dotdotdot rest pattern suggestions#156333

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
TaKO8Ki:fix-dotdotdot-rest-pattern-unicode-span
May 8, 2026
Merged

Avoid invalid spans in dotdotdot rest pattern suggestions#156333
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
TaKO8Ki:fix-dotdotdot-rest-pattern-unicode-span

Conversation

@TaKO8Ki
Copy link
Copy Markdown
Member

@TaKO8Ki TaKO8Ki commented May 8, 2026

Fixes #156316

The parser recovers Unicode confusables such as ··· as ..., while keeping the original source span over the multibyte characters.

recover_dotdotdot_rest_pat built its suggestion by subtracting BytePos(1) from the end of that recovered token span. For multibyte characters, that can create a span boundary inside a UTF-8, causing diagnostic emission to ICE.

This changes the suggestion to replace the whole recovered token span with .. instead of slicing off one byte.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 8, 2026

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 8, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 8, 2026

r? @nikomatsakis

rustbot has assigned @nikomatsakis.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 17 candidates

Copy link
Copy Markdown
Member

@Urgau Urgau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me.

View changes since this review

@Urgau
Copy link
Copy Markdown
Member

Urgau commented May 8, 2026

r? Urgau

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 8, 2026

📌 Commit 431017b has been approved by Urgau

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2026
rust-bors Bot pushed a commit that referenced this pull request May 8, 2026
Rollup of 5 pull requests

Successful merges:

 - #156141 (Resolve some cases of #132279 by using the right typing mode in the next solver)
 - #156244 (fix incorrect suggestions in private import diagnostic)
 - #156306 (Move tests consts)
 - #156333 (Avoid invalid spans in dotdotdot rest pattern suggestions)
 - #156337 (rustc-dev-guide subtree update)
@rust-bors rust-bors Bot merged commit eabe462 into rust-lang:main May 8, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 8, 2026
rust-timer added a commit that referenced this pull request May 8, 2026
Rollup merge of #156333 - TaKO8Ki:fix-dotdotdot-rest-pattern-unicode-span, r=Urgau

Avoid invalid spans in dotdotdot rest pattern suggestions

Fixes #156316

The parser recovers Unicode confusables such as `···` as `...`, while keeping the original source span over the multibyte characters.

`recover_dotdotdot_rest_pat` built its suggestion by subtracting `BytePos(1)` from the end of that recovered token span. For multibyte characters, that can create a span boundary inside a UTF-8, causing diagnostic emission to ICE.

This changes the suggestion to replace the whole recovered token span with `..` instead of slicing off one byte.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32

4 participants