Skip to content

Avoid semicolon suggestion when tail expr is error#152053

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
TaKO8Ki:err-tail-semicolon-suggest
Feb 4, 2026
Merged

Avoid semicolon suggestion when tail expr is error#152053
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
TaKO8Ki:err-tail-semicolon-suggest

Conversation

@TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Feb 3, 2026

Fixes #151610

When the tail expression is Err due to recovery, HIR constructs StmtKind::Semi(Err(..)). The suggestion path then uses stmt.span.with_lo(tail_expr.span.hi()) to target the semicolon, but stmt.span == tail_expr.span so the derived span is empty/invalid.

@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 Feb 3, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 3, 2026

r? @nnethercote

rustbot has assigned @nnethercote.
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

@rust-log-analyzer

This comment has been minimized.

add a link to the issue

fix test stderr
@TaKO8Ki TaKO8Ki force-pushed the err-tail-semicolon-suggest branch from 185f927 to d329971 Compare February 3, 2026 16:16
@nnethercote
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 4, 2026

📌 Commit d329971 has been approved by nnethercote

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 Feb 4, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 4, 2026
…, r=nnethercote

Avoid semicolon suggestion when tail expr is error

Fixes rust-lang#151610

When the tail expression is Err due to recovery, HIR constructs `StmtKind::Semi(Err(..))`. The suggestion path then uses `stmt.span.with_lo(tail_expr.span.hi())` to target the semicolon, but `stmt.span == tail_expr.span` so the derived span is empty/invalid.
rust-bors bot pushed a commit that referenced this pull request Feb 4, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #151893 (Move the query list into a new `rustc_middle::queries` module)
 - #152060 (ci: Optimize loongarch64-linux dist builders)
 - #151993 (Add uv to the list of possible python runners)
 - #152047 (Convert to inline diagnostics in `rustc_interface`)
 - #152053 (Avoid semicolon suggestion when tail expr is error)

Failed merges:

 - #152023 (Some `rustc_query_system` cleanups)
@rust-bors rust-bors bot merged commit b8755a4 into rust-lang:main Feb 4, 2026
11 checks passed
rust-timer added a commit that referenced this pull request Feb 4, 2026
Rollup merge of #152053 - TaKO8Ki:err-tail-semicolon-suggest, r=nnethercote

Avoid semicolon suggestion when tail expr is error

Fixes #151610

When the tail expression is Err due to recovery, HIR constructs `StmtKind::Semi(Err(..))`. The suggestion path then uses `stmt.span.with_lo(tail_expr.span.hi())` to target the semicolon, but `stmt.span == tail_expr.span` so the derived span is empty/invalid.
@rustbot rustbot added this to the 1.95.0 milestone Feb 4, 2026
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]: Span must not be empty and have no suggestion

4 participants