Skip to content

RangeInclusive<T>.exhausted is set inconsistently #164633

Open

Description

@fs-rachel

While looking at the implementation of RangeInclusive<T>, I noticed that the exhausted field is set under different conditions depending on what methods you call.

It looks like originally, the exhausted flag was set whenever the range became empty due to start moving past end (or vice versa).

Then #155114 updated the next, nth, next_back and nth_back methods to set the exhausted flag only when an arithmetic overflow occurs. But it left spec_try_fold and spec_try_rfold with the previous behaviour.

This leaves the logic in an inconsistent state. Ideally the spec_try_(r)fold functions should be updated to use the same conditions as the other methods.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 20, 2026
  2. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-iteratorsArea: IteratorsC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions