Skip to content

Type which uses const generics leads to ICE when using Derive #60724

Closed
@Matthias247

Description

@Matthias247

This code

#![feature(const_generics)]

#[derive(Debug)]
struct X<const N: usize> {
    a: [u32; N],
}

leads to

 --> src/lib.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^

error[E0107]: wrong number of const arguments: expected 1, found 0

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `[type error]`,
 right: `usize`', src/librustc/ty/sty.rs:2279:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

It doesn't seem Debug related, since the same happens for deriving Copy.

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions