Skip to content

[ICE] in inner const generic function  #75299

Closed

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

Activity

  1. leonardo-m commented on Aug 8, 2020

    @leonardo-m
    Author

    The problem is not tied to box:

    #![feature(const_generics)]
    #![allow(incomplete_features)]
    fn main() {
        fn foo<const N: usize>() -> [u8; N] {
            [0; N]
        }
        let _x = foo::<1>();
    }
  2. changed the title [-][ICE] with box in const generic function [/-] [+][ICE] in inner const generic function [/+] on Aug 8, 2020
  3. added
    A-const-genericsArea: const generics (parameters and arguments)
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    on Aug 8, 2020
  4. Alexendoo commented on Sep 7, 2020

    @Alexendoo
    Member

    No longer ICEs after #76376

  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Sep 7, 2020
  6. leonardo-m commented on Sep 7, 2020

    @leonardo-m
    Author

    Ops, sorry, I reopen until a test is present.

  7. added a commit that references this issue on Oct 3, 2020
    a341710
  8. added a commit that references this issue on Oct 4, 2020
    f09c962
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-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. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions