rust-lang / rust-lang/rust

ICE: `enum variant discr was too generic to eval`

Open
#148,888 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-type_alias_impl_trait I-ICE S-bug-has-test S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![feature(type_alias_impl_trait)]

type Foo = impl Send;

trait Trait {
    const CONST: u32;
}

impl Trait for Foo {
    const CONST: u32 = 0;
}

#[repr(u32)]
enum QSelfInConst {
    Variant = <Foo as Trait>::CONST,
}

fn main() {}

A mutant of tests/ui/proc-macro/crate-var.rs

Meta

rustc --version --verbose:

rustc 1.93.0-nightly (01867557c 2025-11-12)
binary: rustc
commit-hash: 01867557cd7dbe256a031a7b8e28d05daecd75ab
commit-date: 2025-11-12
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.5
Error output
error: unconstrained opaque type
 --> 01.rs:3:12
  |
3 | type Foo = impl Send;
  |            ^^^^^^^^^
  |
  = note: `Foo` must be used in combination with a concrete type within the same crate

error: internal compiler error: compiler/rustc_hir_analysis/src/check/wfcheck.rs:1098:25: enum variant discr was too generic to eval


thread 'rustc' (219442) panicked at compiler/rustc_hir_analysis/src/check/wfcheck.rs:1098:25:
Box<dyn Any>
Backtrace

thread 'rustc' (219442) panicked at compiler/rustc_hir_analysis/src/check/wfcheck.rs:1098:25:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: rustc_hir_analysis::check::wfcheck::check_type_defn
   8: rustc_hir_analysis::check::check::check_item_type
   9: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  10: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  11: rustc_hir_analysis::check_crate
  12: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  13: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  14: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/jb/Library/CloudStorage/Dropbox/Desk/2503_rustc_ice/251109 ice 보고용/rustc-ice-2025-11-13T04_10_55-49617.txt` to your bug report

query stack during panic:
#0 [check_well_formed] checking that `qself_in_const::QSelfInConst` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `01`
end of query stack
error: aborting due to 2 previous errors

Notes
Duplication Check

@rustbot label +F-type_alias_impl_trait

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided minimal example and inspect compiler/rustc_hir_analysis/src/check/wfcheck.rs around lines 1092-1101, where the ICE is reported. Trace the well-formedness check for QSelfInConst and verify that the example produces a normal diagnostic instead of an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.