Skip to content

ICE when iterating over a u16 range whose bounds exceed 64k #63364

Closed
@apoelstra

Description

@apoelstra

An ICE is observable with this code:

fn part(_: u16) -> u32 {
    1
}

fn main() {
    for n in 100_000.. {
        let _ = part(n);
    }
}
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', src/librustc_lint/types.rs:79:12
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Changing part to take a u32 rather than u16 makes the ICE go away.

Playground link

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions