Skip to content

ICE: enum variant discr was too generic to eval #135208

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

union Foo {
    a: str,
}

enum Bar {
    Boo = { let _: Option<Foo> = None; 0 },
}

Version information

rustc 1.86.0-nightly (fb546ee09 2025-01-07)
binary: rustc
commit-hash: fb546ee09b226bc4dd4b712d35a372d923c4fa54
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6

Possibly related line of code:

// Explicit `enum` discriminant values must const-evaluate successfully.
if let ty::VariantDiscr::Explicit(discr_def_id) = variant.discr {
match tcx.const_eval_poly(discr_def_id) {
Ok(_) => {}
Err(ErrorHandled::Reported(..)) => {}
Err(ErrorHandled::TooGeneric(sp)) => {
span_bug!(sp, "enum variant discr was too generic to eval")
}
}
}
}
check_where_clauses(wfcx, item.span, item.owner_id.def_id);

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

Program output

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

error[E0517]: attribute should be applied to a struct
 --> /tmp/icemaker_global_tempdir.JPm8shtYqkkY/rustc_testrunner_tmpdir_reporting.ay3Lh8DeqrZK/mvce.rs:1:8
  |
1 |   #[repr(simd)]
  |          ^^^^
2 | / union Foo {
3 | |     a: isize,
4 | |     b: (),
5 | | }
  | |_- not a struct

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


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/check/wfcheck.rs:1196:25:
Box<dyn Any>
stack backtrace:
   0:     0x78406dce19ba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h9bf89a0e5f11c1cf
   1:     0x78406e4135e6 - core::fmt::write::h761219e2be291c7a
   2:     0x78406f2d5991 - std::io::Write::write_fmt::h8032e22f9c3bd5b4
   3:     0x78406dce1812 - std::sys::backtrace::BacktraceLock::print::hebb5778cf40ee20f
   4:     0x78406dce3db7 - std::panicking::default_hook::{{closure}}::ha0fa1988f86f132d
   5:     0x78406dce3ba0 - std::panicking::default_hook::hc12d10b4cbb281ec
   6:     0x78406ce54a08 - std[a144ab5c1b85db5]::panicking::update_hook::<alloc[32a577d94c602890]::boxed::Box<rustc_driver_impl[c12604c6ccf9e768]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x78406dce4643 - std::panicking::rust_panic_with_hook::hf8ade0577c2f95bc
   8:     0x78406ce8cf31 - std[a144ab5c1b85db5]::panicking::begin_panic::<rustc_errors[f4fe76fe817796ae]::ExplicitBug>::{closure#0}
   9:     0x78406ce82116 - std[a144ab5c1b85db5]::sys::backtrace::__rust_end_short_backtrace::<std[a144ab5c1b85db5]::panicking::begin_panic<rustc_errors[f4fe76fe817796ae]::ExplicitBug>::{closure#0}, !>
  10:     0x78406ce82103 - std[a144ab5c1b85db5]::panicking::begin_panic::<rustc_errors[f4fe76fe817796ae]::ExplicitBug>
  11:     0x78406ce96e91 - <rustc_errors[f4fe76fe817796ae]::diagnostic::BugAbort as rustc_errors[f4fe76fe817796ae]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x78406d3e622c - <rustc_errors[f4fe76fe817796ae]::DiagCtxtHandle>::span_bug::<rustc_span[80f3292a29acebce]::span_encoding::Span, alloc[32a577d94c602890]::string::String>
  13:     0x78406d46b457 - rustc_middle[71fc52d0577df4e0]::util::bug::opt_span_bug_fmt::<rustc_span[80f3292a29acebce]::span_encoding::Span>::{closure#0}
  14:     0x78406d45044a - rustc_middle[71fc52d0577df4e0]::ty::context::tls::with_opt::<rustc_middle[71fc52d0577df4e0]::util::bug::opt_span_bug_fmt<rustc_span[80f3292a29acebce]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x78406d4502db - rustc_middle[71fc52d0577df4e0]::ty::context::tls::with_context_opt::<rustc_middle[71fc52d0577df4e0]::ty::context::tls::with_opt<rustc_middle[71fc52d0577df4e0]::util::bug::opt_span_bug_fmt<rustc_span[80f3292a29acebce]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x78406bed63c7 - rustc_middle[71fc52d0577df4e0]::util::bug::span_bug_fmt::<rustc_span[80f3292a29acebce]::span_encoding::Span>
  17:     0x78406eb32c5b - rustc_hir_analysis[58b1087c7a4e8d77]::check::wfcheck::check_type_defn
  18:     0x78406eb2c62e - rustc_hir_analysis[58b1087c7a4e8d77]::check::wfcheck::check_well_formed
  19:     0x78406eb2b363 - rustc_query_impl[c60017a6d5ec95c8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c60017a6d5ec95c8]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 1usize]>>
  20:     0x78406eb2ae05 - rustc_query_system[e4307e8df47736e2]::query::plumbing::try_execute_query::<rustc_query_impl[c60017a6d5ec95c8]::DynamicConfig<rustc_data_structures[228ab352de195f7]::vec_cache::VecCache<rustc_span[80f3292a29acebce]::def_id::LocalDefId, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[e4307e8df47736e2]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[c60017a6d5ec95c8]::plumbing::QueryCtxt, false>
  21:     0x78406eb2a881 - rustc_query_impl[c60017a6d5ec95c8]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  22:     0x78406eb27cac - rustc_hir_analysis[58b1087c7a4e8d77]::check::wfcheck::check_mod_type_wf
  23:     0x78406eb27acb - rustc_query_impl[c60017a6d5ec95c8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c60017a6d5ec95c8]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 1usize]>>
  24:     0x78406f392988 - rustc_query_system[e4307e8df47736e2]::query::plumbing::try_execute_query::<rustc_query_impl[c60017a6d5ec95c8]::DynamicConfig<rustc_query_system[e4307e8df47736e2]::query::caches::DefaultCache<rustc_span[80f3292a29acebce]::def_id::LocalModDefId, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c60017a6d5ec95c8]::plumbing::QueryCtxt, false>
  25:     0x78406f392730 - rustc_query_impl[c60017a6d5ec95c8]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  26:     0x78406e778d78 - rustc_hir_analysis[58b1087c7a4e8d77]::check_crate
  27:     0x78406e6ba668 - rustc_interface[26e69c7fcb6d2c01]::passes::run_required_analyses
  28:     0x78406f2d981e - rustc_interface[26e69c7fcb6d2c01]::passes::analysis
  29:     0x78406f2d97ef - rustc_query_impl[c60017a6d5ec95c8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c60017a6d5ec95c8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 0usize]>>
  30:     0x78406f3b7695 - rustc_query_system[e4307e8df47736e2]::query::plumbing::try_execute_query::<rustc_query_impl[c60017a6d5ec95c8]::DynamicConfig<rustc_query_system[e4307e8df47736e2]::query::caches::SingleCache<rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c60017a6d5ec95c8]::plumbing::QueryCtxt, false>
  31:     0x78406f3b73ce - rustc_query_impl[c60017a6d5ec95c8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x78406f30431e - rustc_interface[26e69c7fcb6d2c01]::passes::create_and_enter_global_ctxt::<core[465b72dbeda08b19]::option::Option<rustc_interface[26e69c7fcb6d2c01]::queries::Linker>, rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  33:     0x78406f377724 - rustc_interface[26e69c7fcb6d2c01]::interface::run_compiler::<(), rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}>::{closure#1}
  34:     0x78406f1f8007 - std[a144ab5c1b85db5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_with_globals<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_pool_with_globals<rustc_interface[26e69c7fcb6d2c01]::interface::run_compiler<(), rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x78406f1f84a4 - <<std[a144ab5c1b85db5]::thread::Builder>::spawn_unchecked_<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_with_globals<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_pool_with_globals<rustc_interface[26e69c7fcb6d2c01]::interface::run_compiler<(), rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[465b72dbeda08b19]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x78406f1f9a6f - std::sys::pal::unix::thread::Thread::new::thread_start::hf3e31ce7c291fa9b
  37:     0x7840696a339d - <unknown>
  38:     0x78406972849c - <unknown>
  39:                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.86.0-nightly (fb546ee09 2025-01-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `Bar` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions