Skip to content

rustc_errors: preserve order of stashed diagnostics when stealing - #162855

Open
kn1g78 wants to merge 2 commits into
rust-lang:mainfrom
kn1g78:fix-stash-steal-diagnostic-order
Open

kn1g78 wants to merge 2 commits into
rust-lang:mainfrom
kn1g78:fix-stash-steal-diagnostic-order

Conversation

@kn1g78

@kn1g78 kn1g78 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Fix the ordering of stashed diagnostics when one of them is stolen.

stashed_diagnostics is an order-preserving map. However, the diagnostic
stealing helpers currently use swap_remove, which moves the last entry
into the position of the removed entry.

As a result, stealing a diagnostic can unexpectedly reorder the remaining
stashed diagnostics.

Use shift_remove instead, which removes the requested entry while
preserving the order of all remaining entries.

Add a regression test covering this behavior by stashing diagnostics
A, B, and C, stealing A, and verifying that the remaining
diagnostics are emitted in the original order:

B
C

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 16, 2026
@rust-log-analyzer

This comment has been minimized.

@kn1g78
kn1g78 marked this pull request as ready for review September 17, 2026 11:01
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 17, 2026
@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
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 77 candidates
  • Random selection from 22 candidates

@rust-bors

rust-bors Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #163111) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants