Skip to content

Avoid improper spans when ... or ..= is recovered from non-ASCII#155820

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Zalathar:range
Apr 26, 2026
Merged

Avoid improper spans when ... or ..= is recovered from non-ASCII#155820
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Zalathar:range

Conversation

@Zalathar
Copy link
Copy Markdown
Member

Adjusting span endpoints by BytePos(1) is almost always bad news.

In this case, the code assumed that it was skipping over a single ASCII character. But in the presence of parser recovery from other non-ASCII characters this resulted in an ICE due to bad string indexing when emitting suggestions.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 26, 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 Apr 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 26, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
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 19 candidates

Copy link
Copy Markdown
Member

@Kivooeo Kivooeo left a comment

Choose a reason for hiding this comment

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

r=me with ci green

View changes since this review

@Kivooeo Kivooeo assigned Kivooeo and unassigned chenyukang Apr 26, 2026
@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented Apr 26, 2026

In this case, the code assumed that it was skipping over a single ASCII character. But in the presence of parser recovery from other non-ASCII characters this resulted in an ICE due to bad string indexing when emitting suggestions.

Another example of this is #155428

@Zalathar
Copy link
Copy Markdown
Member Author

@bors r=Kivooeo rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 26, 2026

📌 Commit 9ceed25 has been approved by Kivooeo

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 Apr 26, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 26, 2026
Avoid improper spans when `...` or `..=` is recovered from non-ASCII

- Fixes rust-lang#155799

Adjusting span endpoints by `BytePos(1)` is almost always bad news.

In this case, the code assumed that it was skipping over a single ASCII character. But in the presence of parser recovery from other non-ASCII characters this resulted in an ICE due to bad string indexing when emitting suggestions.
rust-bors Bot pushed a commit that referenced this pull request Apr 26, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #152995 (ACP Implementation of PermissionsExt for Windows )
 - #153457 (prevent deref coercions in `pin!`)
 - #155250 (Windows: Cache the pipe filesystem handle)
 - #155574 (Move `std::io::RawOsError` to `core::io`)
 - #155757 (macro_metavar_expr_concat: explain why idents are invalid)
 - #155823 (miri subtree update)
 - #155693 (Suggest enclosing format string with `""` under special cases)
 - #155707 (Fix minor panic-unsoundness in CString::clone_into)
 - #155719 (Suggest `.iter()` for shared projections)
 - #155779 (ssa_range_prop: use `if let` guards)
 - #155789 (Cleanups to `AttributeExt`)
 - #155805 (Mention `DEPRECATED_LLVM_INTRINSIC` lint for internal use)
 - #155806 (Remove the incomplete marker from `impl` restrictions)
 - #155820 (Avoid improper spans when `...` or `..=` is recovered from non-ASCII)
 - #155822 (Add default field values to diagnostic FormatArgs)
@rust-bors rust-bors Bot merged commit ae77516 into rust-lang:main Apr 26, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 26, 2026
@Zalathar Zalathar deleted the range branch April 26, 2026 23:57
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Apr 30, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#152995 (ACP Implementation of PermissionsExt for Windows )
 - rust-lang/rust#153457 (prevent deref coercions in `pin!`)
 - rust-lang/rust#155250 (Windows: Cache the pipe filesystem handle)
 - rust-lang/rust#155574 (Move `std::io::RawOsError` to `core::io`)
 - rust-lang/rust#155757 (macro_metavar_expr_concat: explain why idents are invalid)
 - rust-lang/rust#155823 (miri subtree update)
 - rust-lang/rust#155693 (Suggest enclosing format string with `""` under special cases)
 - rust-lang/rust#155707 (Fix minor panic-unsoundness in CString::clone_into)
 - rust-lang/rust#155719 (Suggest `.iter()` for shared projections)
 - rust-lang/rust#155779 (ssa_range_prop: use `if let` guards)
 - rust-lang/rust#155789 (Cleanups to `AttributeExt`)
 - rust-lang/rust#155805 (Mention `DEPRECATED_LLVM_INTRINSIC` lint for internal use)
 - rust-lang/rust#155806 (Remove the incomplete marker from `impl` restrictions)
 - rust-lang/rust#155820 (Avoid improper spans when `...` or `..=` is recovered from non-ASCII)
 - rust-lang/rust#155822 (Add default field values to diagnostic FormatArgs)
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]: assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32

5 participants