Skip to content

ICE when into_iter() is called on a const generic array of type T where size is unkown. #64087

Closed
@goddessfreya

Description

@goddessfreya

Might be similar to #60744, idk.

This causes an ICE:

#![feature(const_generics)]

fn combinator<T, const S: usize>() -> [T; S] {}

fn main() {
    combinator().into_iter();
}

Backtrace: https://gist.github.com/ZeGentzy/d8a1eaa26fe3551e0c5590885265884a

So does this:

#![feature(const_generics)]

fn combinator<T, const S: usize>(a: T) -> [T; S] {}

fn main() {
    let a = 1u8;
    combinator(a).into_iter();
}

Backtrace: https://gist.github.com/ZeGentzy/5ab1bd3ebdd272ad7d51d71fa5a564ec

This does not:

#![feature(const_generics)]

fn combinator<T, const S: usize>() -> [T; S] {}

fn main() {
    combinator::<_, {3}>().into_iter();
}

Nor does this:

#![feature(const_generics)]

fn combinator<T, const S: usize>() -> [T; S] {}

fn main() {
    combinator::<u8, {3}>().into_iter();
}

But this does produce an ICE:

#![feature(const_generics)]

fn combinator<T, const S: usize>() -> [T; S] {}

fn main() {
    combinator::<u8>().into_iter();
}

Backtrace: https://gist.github.com/ZeGentzy/daca993eabfa2e2fe1f340384f93cdb2

System info:

$ clang --version
clang version 10.0.0 (/startdir/llvm-project64 20b2708c18258efe01bc9b785e413362bcc1961c)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ rustc --version      
rustc 1.39.0-nightly (4295eea90 2019-08-30)

This ICE could not be reproduced on the playground's version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-incr-compArea: Incremental compilationF-const_generics`#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions