Skip to content

Conditional char counter not recognized as never-overflowing #143959

Open
@Rudxain

Description

@Rudxain

When conditionally incrementing a usize counter by 1, the optimizer doesn't detect that overflow is impossible, when using the Chars iterator. As an example, I wrote a lines-of-codecontent counter that iterates over chars: Playground

Can repro on 1.90.0-nightly (2025-07-14 a001497)

@rustbot label: +I-slow

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sliceArea: `[T]`C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler 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