rust-lang / rust-lang/rust

[ICE]: discriminant: None

Open
#153,758 3 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

C-bug I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

snippet:

#[derive(Debug, PartialEq)]
enum Bar {
    C = -1,
    D = 1,
    F = i64a,
}

fn main() {
    let val: Bar = unsafe { std::mem::transmute(i64::MIN) };
    assert_eq!(val, Bar::F);
}

Version information

rustc 1.96.0-nightly (d1ee5e59a 2026-03-11)
binary: rustc
commit-hash: d1ee5e59a964a419b84b760812a35075034f4861
commit-date: 2026-03-11
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/d1ee5e59a964a419b84b760812a35075034f4861/compiler/rustc_const_eval/src/interpret/discriminant.rs#L122-L134

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

Program output

error[E0425]: cannot find value `i64a` in this scope
 --> /tmp/icemaker_global_tempdir.vDbeV7nNKWaJ/rustc_testrunner_tmpdir_reporting.R1HH6sPCNHAR/mvce.rs:5:9
  |
5 |     F = i64a,
  |         ^^^^ not found in this scope

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
 --> /tmp/icemaker_global_tempdir.vDbeV7nNKWaJ/rustc_testrunner_tmpdir_reporting.R1HH6sPCNHAR/mvce.rs:9:29
  |
9 |     let val: Bar = unsafe { std::mem::transmute(i64::MIN) };
  |                             ^^^^^^^^^^^^^^^^^^^
  |
  = note: source type: `i64` (64 bits)
  = note: target type: `Bar` (8 bits)


thread 'rustc' (1053030) panicked at /rustc-dev/d1ee5e59a964a419b84b760812a35075034f4861/compiler/rustc_const_eval/src/interpret/discriminant.rs:128:93:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fe05a535ecb - <<std[26ed33ccef5af25d]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[910442c93c00dc89]::fmt::Display>::fmt
   1:     0x7fe05ac1d688 - core[910442c93c00dc89]::fmt::write
   2:     0x7fe05a54ced6 - <std[26ed33ccef5af25d]::sys::stdio::unix::Stderr as std[26ed33ccef5af25d]::io::Write>::write_fmt
   3:     0x7fe05a50bfb8 - std[26ed33ccef5af25d]::panicking::default_hook::{closure#0}
   4:     0x7fe05a529343 - std[26ed33ccef5af25d]::panicking::default_hook
   5:     0x7fe059524b6c - std[26ed33ccef5af25d]::panicking::update_hook::<alloc[ecdb6c814cc93b88]::boxed::Box<rustc_driver_impl[f198289b45e15655]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fe05a529622 - std[26ed33ccef5af25d]::panicking::panic_with_hook
   7:     0x7fe05a50c0aa - std[26ed33ccef5af25d]::panicking::panic_handler::{closure#0}
   8:     0x7fe05a5005c9 - std[26ed33ccef5af25d]::sys::backtrace::__rust_end_short_backtrace::<std[26ed33ccef5af25d]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fe05a50dadd - __rustc[a8b6dc02037f16c]::rust_begin_unwind
  10:     0x7fe0570fa79c - core[910442c93c00dc89]::panicking::panic_fmt
  11:     0x7fe056bf2802 - core[910442c93c00dc89]::panicking::panic
  12:     0x7fe05776be19 - core[910442c93c00dc89]::option::unwrap_failed
  13:     0x7fe05b0dccb4 - <rustc_const_eval[5fab59523de0400a]::interpret::validity::ValidityVisitor<rustc_const_eval[5fab59523de0400a]::const_eval::machine::CompileTimeMachine> as rustc_const_eval[5fab59523de0400a]::interpret::visitor::ValueVisitor<rustc_const_eval[5fab59523de0400a]::const_eval::machine::CompileTimeMachine>>::walk_value
  14:     0x7fe05b0d7047 - <rustc_const_eval[5fab59523de0400a]::interpret::validity::ValidityVisitor<rustc_const_eval[5fab59523de0400a]::const_eval::machine::CompileTimeMachine> as rustc_const_eval[5fab59523de0400a]::interpret::visitor::ValueVisitor<rustc_const_eval[5fab59523de0400a]::const_eval::machine::CompileTimeMachine>>::visit_value
  15:     0x7fe05b0d4816 - rustc_const_eval[5fab59523de0400a]::const_eval::eval_queries::intern_and_validate::<rustc_middle[d3ab91536bfa73ff]::mir::consts::ConstAlloc>
  16:     0x7fe05bcc4d4f - rustc_const_eval[5fab59523de0400a]::const_eval::eval_queries::eval_to_allocation_raw_provider
  17:     0x7fe05bcc2096 - rustc_query_impl[fe7691eaa87f439c]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7fe05aef2183 - rustc_query_impl[fe7691eaa87f439c]::execution::try_execute_query::<rustc_middle[d3ab91536bfa73ff]::query::caches::DefaultCache<rustc_middle[d3ab91536bfa73ff]::ty::PseudoCanonicalInput<rustc_middle[d3ab91536bfa73ff]::mir::interpret::GlobalId>, rustc_middle[d3ab91536bfa73ff]::query::erase::ErasedData<[u8; 24usize]>>, false>
  19:     0x7fe05aef1b53 - rustc_query_impl[fe7691eaa87f439c]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7fe05aef0a3a - rustc_const_eval[5fab59523de0400a]::const_eval::eval_queries::eval_to_const_value_raw_provider
  21:     0x7fe05aef05a4 - rustc_query_impl[fe7691eaa87f439c]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7fe05aef2082 - rustc_query_impl[fe7691eaa87f439c]::execution::try_execute_query::<rustc_middle[d3ab91536bfa73ff]::query::caches::DefaultCache<rustc_middle[d3ab91536bfa73ff]::ty::PseudoCanonicalInput<rustc_middle[d3ab91536bfa73ff]::mir::interpret::GlobalId>, rustc_middle[d3ab91536bfa73ff]::query::erase::ErasedData<[u8; 24usize]>>, false>
  23:     0x7fe05aef1c0b - rustc_query_impl[fe7691eaa87f439c]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7fe05b63826f - <rustc_middle[d3ab91536bfa73ff]::ty::context::TyCtxt>::const_eval_resolve
  25:     0x7fe05b29f8e1 - <rustc_mir_transform[6b3f516ad7572e3d]::known_panics_lint::ConstPropagator as rustc_middle[d3ab91536bfa73ff]::mir::visit::Visitor>::visit_assign
  26:     0x7fe05b29b84a - <rustc_mir_transform[6b3f516ad7572e3d]::known_panics_lint::ConstPropagator as rustc_middle[d3ab91536bfa73ff]::mir::visit::Visitor>::visit_body
  27:     0x7fe05b298b04 - <rustc_mir_transform[6b3f516ad7572e3d]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[6b3f516ad7572e3d]::pass_manager::MirLint>::run_lint
  28:     0x7fe05ac0d23c - rustc_mir_transform[6b3f516ad7572e3d]::run_analysis_to_runtime_passes
  29:     0x7fe05b154a44 - rustc_mir_transform[6b3f516ad7572e3d]::mir_drops_elaborated_and_const_checked
  30:     0x7fe05b1544b5 - rustc_query_impl[fe7691eaa87f439c]::query_impl::mir_drops_elaborated_and_const_checked::invoke_provider_fn::__rust_begin_short_backtrace
  31:     0x7fe05ad42429 - rustc_query_impl[fe7691eaa87f439c]::execution::try_execute_query::<rustc_data_structures[b876b373b95aba84]::vec_cache::VecCache<rustc_span[43688b2c23b102cd]::def_id::LocalDefId, rustc_middle[d3ab91536bfa73ff]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[d3ab91536bfa73ff]::dep_graph::graph::DepNodeIndex>, false>
  32:     0x7fe05ad41b83 - rustc_query_impl[fe7691eaa87f439c]::query_impl::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7fe05ad44888 - <rustc_middle[d3ab91536bfa73ff]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[6db8d6c7beeb3a02]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  34:     0x7fe05ad43c73 - rustc_interface[6db8d6c7beeb3a02]::passes::analysis
  35:     0x7fe05be403c9 - rustc_query_impl[fe7691eaa87f439c]::execution::try_execute_query::<rustc_middle[d3ab91536bfa73ff]::query::caches::SingleCache<rustc_middle[d3ab91536bfa73ff]::query::erase::ErasedData<[u8; 0usize]>>, false>
  36:     0x7fe05be40035 - rustc_query_impl[fe7691eaa87f439c]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7fe05bdec5c8 - rustc_interface[6db8d6c7beeb3a02]::interface::run_compiler::<(), rustc_driver_impl[f198289b45e15655]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7fe05be22b3e - std[26ed33ccef5af25d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6db8d6c7beeb3a02]::util::run_in_thread_with_globals<rustc_interface[6db8d6c7beeb3a02]::util::run_in_thread_pool_with_globals<rustc_interface[6db8d6c7beeb3a02]::interface::run_compiler<(), rustc_driver_impl[f198289b45e15655]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x7fe05be233e0 - <std[26ed33ccef5af25d]::thread::lifecycle::spawn_unchecked<rustc_interface[6db8d6c7beeb3a02]::util::run_in_thread_with_globals<rustc_interface[6db8d6c7beeb3a02]::util::run_in_thread_pool_with_globals<rustc_interface[6db8d6c7beeb3a02]::interface::run_compiler<(), rustc_driver_impl[f198289b45e15655]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[910442c93c00dc89]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7fe05be2426c - <std[26ed33ccef5af25d]::sys::thread::unix::Thread>::new::thread_start
  41:     0x7fe0558a598b - <unknown>
  42:     0x7fe055929a0c - <unknown>
  43:                0x0 - <unknown>

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

note: rustc 1.96.0-nightly (d1ee5e59a 2026-03-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `main::promoted[0]`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors

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

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.