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

Activity

added
C-bugCategory: This is a bug.
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.
on Apr 15, 2020
elichai

elichai commented on Apr 15, 2020

@elichai
Contributor

I assume this is the same as: https://play.rust-lang.org/?&gist=485702f1094102226682c7e28f1c848d

use std::mem::size_of;
use std::marker::PhantomData;

struct Raw<T: ?Sized> {
    d: [u8; size_of::<&T>()],
    _p: PhantomData<T>,
}

and: #43408 (comment)

added 3 commits that reference this issue on Jul 16, 2020

Rollup merge of rust-lang#74159 - lcnr:const-generic-ty-decl, r=varkor

ea5affa

Rollup merge of rust-lang#74159 - lcnr:const-generic-ty-decl, r=varkor

e51b3db

Rollup merge of rust-lang#74159 - lcnr:const-generic-ty-decl, r=varkor

6ef0dfa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @jonas-schievink@elichai@leonardo-m@rust-lang-glacier-bot

      Issue actions

        [ICE] with const generics array · Issue #71169 · rust-lang/rust