rust-lang / rust-lang/rust

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

Open
#158,797 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug 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

auto-reduced (treereduce-rust):

#![feature(const_async_blocks)]

enum Foo {
    Bar = (|| yield, 2).1,
}

original:

#![feature(coroutines)]
#![feature(const_async_blocks)]
#![feature(yield_expr)]
enum Foo {
    Bar = (
        #[coroutine]
        || yield,
        2,
    )
        .1,
}

fn main() {}

Version information

rustc 1.98.0-nightly (ea088e0a3 2026-07-05)
binary: rustc
commit-hash: ea088e0a3dd50c494b4589c3c121d7469dceec8f
commit-date: 2026-07-05
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Possibly related line of code:
https://github.com/rust-lang/rust/blob/ea088e0a3dd50c494b4589c3c121d7469dceec8f/compiler/rustc_hir_analysis/src/check/wfcheck.rs#L1132-L1144

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0658]: yield syntax is experimental
 --> /tmp/icemaker_global_tempdir.ptA2QDVmn15G/rustc_testrunner_tmpdir_reporting.L6CW6WUYm6Fw/mvce.rs:4:15
  |
4 |     Bar = (|| yield, 2).1,
  |               ^^^^^
  |
  = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
  = help: add `#![feature(yield_expr)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-05; consider upgrading it if it is out of date

error[E0658]: yield syntax is experimental
 --> /tmp/icemaker_global_tempdir.ptA2QDVmn15G/rustc_testrunner_tmpdir_reporting.L6CW6WUYm6Fw/mvce.rs:4:15
  |
4 |     Bar = (|| yield, 2).1,
  |               ^^^^^
  |
  = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
  = help: add `#![feature(yield_expr)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-05; consider upgrading it if it is out of date

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
 --> /tmp/icemaker_global_tempdir.ptA2QDVmn15G/rustc_testrunner_tmpdir_reporting.L6CW6WUYm6Fw/mvce.rs:4:15
  |
4 |     Bar = (|| yield, 2).1,
  |               ^^^^^
  |
help: use `#[coroutine]` to make this closure a coroutine
  |
4 |     Bar = (#[coroutine] || yield, 2).1,
  |            ++++++++++++

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.ptA2QDVmn15G/rustc_testrunner_tmpdir_reporting.L6CW6WUYm6Fw/mvce.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.ptA2QDVmn15G/rustc_testrunner_tmpdir_reporting.L6CW6WUYm6Fw/mvce.rs`

error: internal compiler error: /rustc-dev/ea088e0a3dd50c494b4589c3c121d7469dceec8f/compiler/rustc_hir_analysis/src/check/wfcheck.rs:1138:25: enum variant discr was too generic to eval


thread 'rustc' (2036952) panicked at /rustc-dev/ea088e0a3dd50c494b4589c3c121d7469dceec8f/compiler/rustc_hir_analysis/src/check/wfcheck.rs:1138:25:
Box<dyn Any>
stack backtrace:
   0:     0x7fce060e5ea6 - <<std[1023ab8fe43ea5ab]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[ac254214b649f1de]::fmt::Display>::fmt
   1:     0x7fce0680ecc8 - core[ac254214b649f1de]::fmt::write
   2:     0x7fce060fb28c - <std[1023ab8fe43ea5ab]::sys::stdio::unix::Stderr as std[1023ab8fe43ea5ab]::io::Write>::write_fmt
   3:     0x7fce060ba30a - std[1023ab8fe43ea5ab]::panicking::default_hook::{closure#0}
   4:     0x7fce060d85f3 - std[1023ab8fe43ea5ab]::panicking::default_hook
   5:     0x7fce050c45b8 - std[1023ab8fe43ea5ab]::panicking::update_hook::<alloc[e3e2338491c50a85]::boxed::Box<rustc_driver_impl[cdfcb04387bfb2d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fce060d8a92 - std[1023ab8fe43ea5ab]::panicking::panic_with_hook
   7:     0x7fce050f20e1 - std[1023ab8fe43ea5ab]::panicking::begin_panic::<rustc_errors[d242d9a7579ddf78]::ExplicitBug>::{closure#0}
   8:     0x7fce050eae56 - std[1023ab8fe43ea5ab]::sys::backtrace::__rust_end_short_backtrace::<std[1023ab8fe43ea5ab]::panicking::begin_panic<rustc_errors[d242d9a7579ddf78]::ExplicitBug>::{closure#0}, !>
   9:     0x7fce050e8e97 - std[1023ab8fe43ea5ab]::panicking::begin_panic::<rustc_errors[d242d9a7579ddf78]::ExplicitBug>
  10:     0x7fce050fd271 - <rustc_errors[d242d9a7579ddf78]::diagnostic::BugAbort as rustc_errors[d242d9a7579ddf78]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fce05649cdc - <rustc_errors[d242d9a7579ddf78]::DiagCtxtHandle>::span_bug::<rustc_span[1809dac9b9f9f1f9]::span_encoding::Span, alloc[e3e2338491c50a85]::string::String>
  12:     0x7fce056787f6 - rustc_middle[65e93962a5a43da7]::util::bug::opt_span_bug_fmt::<rustc_span[1809dac9b9f9f1f9]::span_encoding::Span>::{closure#0}
  13:     0x7fce05678982 - rustc_middle[65e93962a5a43da7]::ty::context::tls::with_opt::<rustc_middle[65e93962a5a43da7]::util::bug::opt_span_bug_fmt<rustc_span[1809dac9b9f9f1f9]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7fce056640cb - rustc_middle[65e93962a5a43da7]::ty::context::tls::with_context_opt::<rustc_middle[65e93962a5a43da7]::ty::context::tls::with_opt<rustc_middle[65e93962a5a43da7]::util::bug::opt_span_bug_fmt<rustc_span[1809dac9b9f9f1f9]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7fce030d0a68 - rustc_middle[65e93962a5a43da7]::util::bug::span_bug_fmt::<rustc_span[1809dac9b9f9f1f9]::span_encoding::Span>
  16:     0x7fce070cbff7 - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_type_defn
  17:     0x7fce076b7164 - rustc_hir_analysis[6a1607dc5c50ec45]::check::check::check_item_type
  18:     0x7fce076b03b0 - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_well_formed
  19:     0x7fce076b0391 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7fce076af971 - rustc_query_impl[e6cc49fff9d6167b]::execution::try_execute_query::<rustc_data_structures[1a2aab4d02078da7]::vec_cache::VecCache<rustc_span[1809dac9b9f9f1f9]::def_id::LocalDefId, rustc_middle[65e93962a5a43da7]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[65e93962a5a43da7]::dep_graph::graph::DepNodeIndex>, false>
  21:     0x7fce076af707 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7fce076ac185 - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_type_wf
  23:     0x7fce076ac093 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7fce07985186 - rustc_query_impl[e6cc49fff9d6167b]::execution::try_execute_query::<rustc_middle[65e93962a5a43da7]::query::caches::SingleCache<rustc_middle[65e93962a5a43da7]::query::erase::ErasedData<[u8; 1usize]>>, false>
  25:     0x7fce07984f69 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7fce06bd6b9a - rustc_hir_analysis[6a1607dc5c50ec45]::check_crate
  27:     0x7fce06bdb1ba - rustc_interface[a6d30ce4ed30ee91]::passes::analysis
  28:     0x7fce07983707 - rustc_query_impl[e6cc49fff9d6167b]::execution::try_execute_query::<rustc_middle[65e93962a5a43da7]::query::caches::SingleCache<rustc_middle[65e93962a5a43da7]::query::erase::ErasedData<[u8; 0usize]>>, false>
  29:     0x7fce07983369 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7fce07959e40 - rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler::<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7fce0799227a - std[1023ab8fe43ea5ab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_with_globals<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_pool_with_globals<rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7fce0799202d - <std[1023ab8fe43ea5ab]::thread::lifecycle::spawn_unchecked<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_with_globals<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_pool_with_globals<rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ac254214b649f1de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fce07996450 - <std[1023ab8fe43ea5ab]::sys::thread::unix::Thread>::new::thread_start
  34:     0x7fce012981b9 - <unknown>
  35:     0x7fce0131d21c - <unknown>
  36:                0x0 - <unknown>

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: rustc 1.98.0-nightly (ea088e0a3 2026-07-05) running on x86_64-unknown-linux-gnu

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

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@rustbot label +F-coroutines +F-const_async_blocks +F-yield_expr

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 reduced a.rs example with the referenced nightly toolchain and inspect compiler/rustc_hir_analysis/src/check/wfcheck.rs around lines 1132–1144, especially check_type_defn. Trace the check_well_formed query shown in the report and add regression coverage for this enum discriminant case. Done means the example no longer triggers the 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
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.