Skip to content

Conversation

@heathdutton
Copy link

@heathdutton heathdutton commented Dec 16, 2025

When pop_front was called while the cursor pointed to the front element, move_next incremented the index but it was never decremented afterwards, causing the index to incorrectly report 1 instead of 0.

Always decrement the index after popping from front using saturating_sub to handle edge cases safely.

Fixes #147616

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2025

r? @Mark-Simulacrum

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

@rustbot

This comment has been minimized.

When `pop_front` was called while the cursor pointed to the front
element, `move_next` incremented the index but it was never decremented
afterwards, causing the index to incorrectly report 1 instead of 0.

Always decrement the index after popping from front using
`saturating_sub` to handle edge cases safely.
@heathdutton heathdutton force-pushed the fix-linked-list-cursor-pop-front-index branch from a4e0832 to 901fe3f Compare December 17, 2025 20:42
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-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect linked_list::CursorMut::pop_front behavior: Index Is Not Updated as Expected

3 participants