Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const generics in enum discriminants cause an ICE #96594

Closed
beepster4096 opened this issue May 1, 2022 · 2 comments
Closed

Const generics in enum discriminants cause an ICE #96594

beepster4096 opened this issue May 1, 2022 · 2 comments
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@beepster4096
Copy link
Contributor

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

@beepster4096 beepster4096 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 1, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 3, 2022
@TaKO8Ki TaKO8Ki self-assigned this May 6, 2022
@lcnr lcnr added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label May 16, 2022
@TaKO8Ki TaKO8Ki removed their assignment Jun 1, 2022
@TaKO8Ki TaKO8Ki assigned TaKO8Ki and unassigned TaKO8Ki Oct 5, 2022
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Oct 5, 2022

Minimal example:

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

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

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=2d338d00f2ef169fe0c65b8606587ffa

@workingjubilee workingjubilee added requires-nightly This issue requires a nightly compiler in some way. requires-incomplete-features This issue requires the use of incomplete features. labels Mar 4, 2023
@Alexendoo
Copy link
Member

Fixed by #111215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features This issue requires the use of incomplete features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants