Skip to content

[ICE] in inner const generic function  #75299

Closed
@leonardo-m

Description

@leonardo-m
#![feature(const_generics, box_syntax)]
#![allow(incomplete_features)]
fn main() {
    fn foo<const N: usize>() {
        box [0; N];
    }
    foo::<1>();
}

Compiled with:
rustc -Z mir-opt-level=3 bug.rs

Using:
rustc 1.47.0-nightly (09f4c9f50 2020-08-07) running on x86_64-pc-windows-gnu

Gives:

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ bug[317d]::main[0]), const_param_did: None }) (
encountered `Assign` statement with incompatible types:
left-hand side has type: [i32; 1]
right-hand side has type: [i32; N]
 --> bug.rs:5:13
  |
5 |         box [0; N];
  |             ^^^^^^
  |
  = note: delayed at src\librustc_mir\transform\validate.rs:140:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src\librustc_errors\lib.rs:366:17

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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