Skip to content

ICE: Trying to match a refutable Slice pattern in a for loop #18032

Closed
@Florob

Description

@Florob

The following code currently produces an ICE:

fn main() {
    let bytes = [1u8, 2, 3, 4, 5, 6, 7, 8];

    for [a, b, c, d] in bytes.chunks(4) {
        println!("{} {} {} {}", a, b, c, d);
    }
}
<anon>:4:9: 4:21 error: internal compiler error: Explicit index of non-index type `core::slice::Chunks<'_,u8>`
<anon>:4     for [a, b, c, d] in bytes.chunks(4) {
                 ^~~~~~~~~~~~
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:113

This should clearly produce a compile time error of course, but not an ICE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions