Skip to content

char open ended range isn't bounded by char::MAX #111514

Open
@ChrisDenton

Description

@ChrisDenton

I tried this code:

for _ in '\0'.. {}

I expected to see this happen: Runs without error.

Instead, this happened:

thread 'main' panicked at 'overflow in `Step::forward`', /rustc/2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd\library\core\src\iter\range.rs:88:45

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (2a8221dbd 2023-05-11)
binary: rustc
commit-hash: 2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd
commit-date: 2023-05-11
host: x86_64-pc-windows-msvc
release: 1.71.0-nightly
LLVM version: 16.0.2
Backtrace

   0: std::panicking::begin_panic_handler
             at /rustc/2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd/library\std\src\panicking.rs:578
   1: core::panicking::panic_fmt
             at /rustc/2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd/library\core\src\panicking.rs:67
   2: core::panicking::panic_display
             at /rustc/2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd/library\core\src\panicking.rs:150
   3: core::panicking::panic_str
             at /rustc/2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd/library\core\src\panicking.rs:134
   4: core::option::expect_failed
             at /rustc/2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd/library\core\src\option.rs:1932
   5: core::iter::range::Step::forward
   6: core::iter::range::<impl core::iter::traits::iterator::Iterator for core::ops::range::RangeFrom<A>>::next
   7: core::fmt::Arguments::new_v1
   8: core::ops::function::FnOnce::call_once

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UnicodeArea: UnicodeC-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