Avoid semicolon suggestion when tail expr is error#152053
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Feb 4, 2026
Merged
Avoid semicolon suggestion when tail expr is error#152053rust-bors[bot] merged 1 commit intorust-lang:mainfrom
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
This comment has been minimized.
This comment has been minimized.
add a link to the issue fix test stderr
185f927 to
d329971
Compare
nnethercote
approved these changes
Feb 4, 2026
Contributor
|
@bors r+ rollup |
Contributor
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.
This was referenced Feb 4, 2026
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-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #151610
When the tail expression is Err due to recovery, HIR constructs
StmtKind::Semi(Err(..)). The suggestion path then usesstmt.span.with_lo(tail_expr.span.hi())to target the semicolon, butstmt.span == tail_expr.spanso the derived span is empty/invalid.