Skip to content

[ICE] with const generics array #71169

Closed
@leonardo-m

Description

@leonardo-m
#![feature(const_generics)]
#![allow(incomplete_features)]
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
fn main() {
    const DATA: [u8; 4] = *b"ABCD";
    foo::<4, DATA>();
}

Gives:

error: internal compiler error: src\librustc_middle\ty\subst.rs:613: const parameter `LEN/#0` (Const { ty: usize, val: Param(LEN/#0) }/0) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', /rustc/edc02580e4e80476ac1ded2cc1008eaf8b8400e6\src\libstd\macros.rs:13:23
...

note: rustc 1.44.0-nightly (edc02580e 2020-04-14) running on x86_64-pc-windows-gnu

query stack during panic:
#0 [resolve_instance] resolving instance `DefId(0:11 ~ const_text_test[317d]::main[0]::{{constant}}[1])` `[]` with ParamEnv { caller_bounds: [], reveal: All, def_id: None }
#1 [typeck_tables_of] type-checking `main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`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.glacierICE tracked in rust-lang/glacier.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