Skip to content

ICE: feature(generic_const_exprs) when assigning a default value for an array using an associated constant of a supertrait as its size #93248

Closed
@teoxoy

Description

@teoxoy

Assigning a default value for an array using an associated constant of a supertrait as its size and trying to compile the following code via either cargo run or cargo build results in an ICE.

Code

#![feature(generic_const_exprs)]

trait Padding {
    const PADDING: usize;
}

trait Pad: Padding
where
    [u8; Self::PADDING]:,
{
    // const VAL: [u8; Self::PADDING]; // - works
    const VAL: [u8; Self::PADDING] = [0; Self::PADDING]; // - doesn't work
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (bfe156467 2022-01-22)
binary: rustc
commit-hash: bfe15646761a75f0259e204cab071565eed2b1e5
commit-date: 2022-01-22
host: x86_64-pc-windows-msvc
release: 1.60.0-nightly
LLVM version: 13.0.0

Error output

warning: Error finalizing incremental compilation session directory `\\?\<PROJECT_ROOT_(REDACTED)>\target\debug\incremental\<PROJECT_NAME_(REDACTED)>-1f04lwri6wcgv\s-g6dujrhxmd-1dqafbx-working`: The system cannot find the file specified. (os error 2)      

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<Self as Padding>, [])` during codegen
  |
  = note: delayed at compiler\rustc_trait_selection\src\traits\codegen.rs:68:32

error: internal compiler error: ty::ConstKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/bfe15646761a75f0259e204cab071565eed2b1e5\compiler\rustc_middle\src\ty\consts.rs:245:43

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler\rustc_errors\src\lib.rs:1188:13
Backtrace

(no backtrace generated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions