Skip to content

Const generics in enum discriminants cause an ICE #96594

Closed
@beepster4096

Description

@beepster4096

Code

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
#![crate_type = "lib"]

#[repr(u8)]
pub enum SomeByte<const VALUE: u8>
where
    [(); VALUE as usize]:,
{
    Value = VALUE,
}

Meta

rustc --version --verbose:

rustc 1.62.0-nightly (7c4b47696 2022-04-30)
binary: rustc
commit-hash: 7c4b47696907d64eff5621a64eb3c6e795a9ec77
commit-date: 2022-04-30
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: enum discriminant depends on generics
  --> ice.rs:10:13
   |
10 |     Value = VALUE,
   |             ^^^^^
   |
   = note: delayed at /rustc/7c4b47696907d64eff5621a64eb3c6e795a9ec77\compiler\rustc_middle\src\ty\adt.rs:460:26

error: internal compiler error: enum discriminant depends on generics
  --> ice.rs:10:13
   |
10 |     Value = VALUE,
   |             ^^^^^
   |
   = note: delayed at compiler\rustc_middle\src\ty\adt.rs:460:26

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1358:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md   

note: rustc 1.62.0-nightly (7c4b47696 2022-04-30) running on x86_64-pc-windows-msvc

query stack during panic:
end of query stack
Backtrace

stack backtrace:
   0:     0x7ff8bd75981f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4a62c20f41e76f07
   1:     0x7ff8bd789cca - core::fmt::write::h2fe5255b2dcdf64c
   2:     0x7ff8bd74bf49 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h3e9a3ad364f2e8ca
   3:     0x7ff8bd75d00b - std::panicking::default_hook::hb0d70aac79902e97
   4:     0x7ff8bd75cbfe - std::panicking::default_hook::hb0d70aac79902e97
   5:     0x7ff8651a83a6 - <rustc_middle[588a68ee0d484b7b]::ty::SymbolName as core[85b4b3ec3e1a751c]::fmt::Debug>::fmt
   6:     0x7ff8bd75d8ea - std::panicking::rust_panic_with_hook::h60185f0484cf873e
   7:     0x7ff869b27775 - <<rustc_errors[b425947c3c3f882f]::json::Diagnostic>::from_errors_diagnostic::BufWriter as std[6ed58db4c3aec449]::io::Write>::flush
   8:     0x7ff869b25529 - <<rustc_errors[b425947c3c3f882f]::json::Diagnostic>::from_errors_diagnostic::BufWriter as std[6ed58db4c3aec449]::io::Write>::flush
   9:     0x7ff869e44959 - rustc_query_system[43367c53c341809a]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff869ae60d9 - <rustc_errors[b425947c3c3f882f]::diagnostic_builder::DiagnosticBuilderInner as core[85b4b3ec3e1a751c]::ops::drop::Drop>::drop
  11:     0x7ff869aea32f - <rustc_errors[b425947c3c3f882f]::HandlerInner as core[85b4b3ec3e1a751c]::ops::drop::Drop>::drop
  12:     0x7ff8651c8394 - rustc_driver[cc87a4417a6f2302]::pretty::print_after_hir_lowering
  13:     0x7ff8651d1f8a - rustc_driver[cc87a4417a6f2302]::pretty::print_after_hir_lowering
  14:     0x7ff8651be58d - rustc_driver[cc87a4417a6f2302]::pretty::print_after_hir_lowering
  15:     0x7ff8651bb6e9 - rustc_driver[cc87a4417a6f2302]::pretty::print_after_hir_lowering
  16:     0x7ff86513d876 - <rustc_privacy[78545dac10f98ba9]::ObsoleteVisiblePrivateTypesVisitor as rustc_hir[3f096969c6f05e8d]::intravisit::Visitor>::visit_expr
  17:     0x7ff86516bb16 - <rustc_driver[cc87a4417a6f2302]::args::Error as core[85b4b3ec3e1a751c]::fmt::Debug>::fmt
  18:     0x7ff86516cb48 - <rustc_driver[cc87a4417a6f2302]::args::Error as core[85b4b3ec3e1a751c]::fmt::Debug>::fmt
  19:     0x7ff8bd76ed5c - std::sys::windows::thread::Thread::new::h632959755be76c89
  20:     0x7ff948c154e0 - BaseThreadInitThunk
  21:     0x7ff94a18485b - RtlUserThreadStart

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`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-incomplete-featuresThis issue requires the use of incomplete features.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