rust-lang / rust-lang/rust

`compiler/rustc_const_eval/src/interpret/discriminant.rs:128` panicked

Open
#154,737 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://github.com/rust-lang/rust/blob/7e46c5f6fb87f8cf4353e058479cef15d1d952b4/compiler/rustc_const_eval/src/interpret/discriminant.rs#L128

thread 'rustc' (1079589) panicked at /rustc-dev/7e46c5f6fb87f8cf4353e058479cef15d1d952b4/compiler/rustc_const_eval/src/interpret/discriminant.rs:128:93:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fd50059337b - <<std[98e825b980ace71a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c0e9ef583ed961cc]::fmt::Display>::fmt
   1:     0x7fd500c30148 - core[c0e9ef583ed961cc]::fmt::write
   2:     0x7fd5005aa386 - <std[98e825b980ace71a]::sys::stdio::unix::Stderr as std[98e825b980ace71a]::io::Write>::write_fmt
   3:     0x7fd500569388 - std[98e825b980ace71a]::panicking::default_hook::{closure#0}
   4:     0x7fd500586783 - std[98e825b980ace71a]::panicking::default_hook
   5:     0x7fd4ff58bb3c - std[98e825b980ace71a]::panicking::update_hook::<alloc[b62ea9019244d580]::boxed::Box<rustc_driver_impl[793884a437c970ce]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd500586a62 - std[98e825b980ace71a]::panicking::panic_with_hook
   7:     0x7fd50056947a - std[98e825b980ace71a]::panicking::panic_handler::{closure#0}
   8:     0x7fd500560179 - std[98e825b980ace71a]::sys::backtrace::__rust_end_short_backtrace::<std[98e825b980ace71a]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fd50056aead - __rustc[a9b4a1fa1acd65d2]::rust_begin_unwind
  10:     0x7fd4fd2d621c - core[c0e9ef583ed961cc]::panicking::panic_fmt
  11:     0x7fd4fcc26de2 - core[c0e9ef583ed961cc]::panicking::panic
  12:     0x7fd4fd27e379 - core[c0e9ef583ed961cc]::option::unwrap_failed
  13:     0x7fd5019d38ec - <rustc_const_eval[45bdc275d819eb8d]::interpret::eval_context::InterpCx<rustc_const_eval[45bdc275d819eb8d]::const_eval::dummy_machine::DummyMachine>>::read_discriminant::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy>
  14:     0x7fd5019d044a - <rustc_mir_dataflow[36cdc4fee7855ab3]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#1}>
  15:     0x7fd5019d0601 - <rustc_mir_dataflow[36cdc4fee7855ab3]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#1}>
  16:     0x7fd5019d0601 - <rustc_mir_dataflow[36cdc4fee7855ab3]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#1}>
  17:     0x7fd5019cf898 - <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_operand
  18:     0x7fd4fe229881 - <rustc_mir_transform[70b01dc83cb28395]::jump_threading::JumpThreading as rustc_mir_transform[70b01dc83cb28395]::pass_manager::MirPass>::run_pass
  19:     0x7fd500c09522 - rustc_mir_transform[70b01dc83cb28395]::run_optimization_passes
  20:     0x7fd501742915 - rustc_mir_transform[70b01dc83cb28395]::optimized_mir
  21:     0x7fd501742561 - rustc_query_impl[cf13977eb46bb4e5]::query_impl::optimized_mir::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7fd500c5084a - rustc_query_impl[cf13977eb46bb4e5]::execution::try_execute_query::<rustc_middle[ba798c852eab49df]::query::caches::DefIdCache<rustc_middle[ba798c852eab49df]::query::erase::ErasedData<[u8; 8usize]>>, false>
  23:     0x7fd500c4fe8e - rustc_query_impl[cf13977eb46bb4e5]::query_impl::optimized_mir::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7fd5017ff74e - <rustc_metadata[150ae410db238ac5]::rmeta::encoder::EncodeContext>::encode_crate_root
  25:     0x7fd5022d53f1 - <rustc_metadata[150ae410db238ac5]::rmeta::encoder::encode_metadata::{closure#3} as core[c0e9ef583ed961cc]::ops::function::FnOnce<(rustc_middle[ba798c852eab49df]::ty::context::TyCtxt, &std[98e825b980ace71a]::path::Path)>>::call_once
  26:     0x7fd5022d2b94 - rustc_metadata[150ae410db238ac5]::rmeta::encoder::encode_metadata
  27:     0x7fd5019a9f49 - rustc_metadata[150ae410db238ac5]::fs::encode_and_write_metadata
  28:     0x7fd501e11948 - <rustc_interface[6373f0af38dffaf7]::queries::Linker>::codegen_and_build_linker
  29:     0x7fd501e0c6cd - rustc_interface[6373f0af38dffaf7]::interface::run_compiler::<(), rustc_driver_impl[793884a437c970ce]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7fd501df67fe - std[98e825b980ace71a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_with_globals<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_pool_with_globals<rustc_interface[6373f0af38dffaf7]::interface::run_compiler<(), rustc_driver_impl[793884a437c970ce]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7fd501df70a0 - <std[98e825b980ace71a]::thread::lifecycle::spawn_unchecked<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_with_globals<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_pool_with_globals<rustc_interface[6373f0af38dffaf7]::interface::run_compiler<(), rustc_driver_impl[793884a437c970ce]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c0e9ef583ed961cc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7fd501df7f2c - <std[98e825b980ace71a]::sys::thread::unix::Thread>::new::thread_start
  33:     0x7fd4fb8a597a - <unknown>
  34:     0x7fd4fb9292bc - <unknown>
  35:                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: please attach the file at `/home/facefire/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sec1-0.7.3/rustc-ice-2026-04-02T23_36_54-1079584.txt` to your bug report

note: rustc 1.96.0-nightly (7e46c5f6f 2026-04-01) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C strip=debuginfo

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [optimized_mir] optimizing MIR for `point::<impl at /home/facefire/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sec1-0.7.3/src/point.rs:79:1: 81:23>::from_bytes`
end of query stack
error: could not compile `sec1` (lib)

Caused by:
  process didn't exit successfully: `/home/facefire/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name sec1 --edition=2021 /home/facefire/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sec1-0.7.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=212 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="alloc"' --cfg 'feature="point"' --cfg 'feature="std"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("alloc", "default", "der", "pem", "pkcs8", "point", "serde", "std", "subtle", "zeroize"))' -C metadata=d3812d6e159ec697 -C extra-filename=-1f2d3e1762c10c68 --out-dir /home/facefire/toublier/target/release/deps -C strip=debuginfo -L dependency=/home/facefire/toublier/target/release/deps --extern base16ct=/home/facefire/toublier/target/release/deps/libbase16ct-84787d38dae0ff68.rmeta --extern generic_array=/home/facefire/toublier/target/release/deps/libgeneric_array-8e0160c0fdd1d79f.rmeta --cap-lints allow` (exit status: 101)
warning: build failed, waiting for other jobs to finish...
facefire@facefire-main ~/toublier (master) [101]> cat /home/facefire/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sec1-0.7.3/rustc-ice-2026-04-02T23_36_54-1079584.txt
thread 'rustc' panicked at /rustc-dev/7e46c5f6fb87f8cf4353e058479cef15d1d952b4/compiler/rustc_const_eval/src/interpret/discriminant.rs:128:93:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fd500573f6b - <std[98e825b980ace71a]::backtrace::Backtrace>::create
   1:     0x7fd500573eb5 - <std[98e825b980ace71a]::backtrace::Backtrace>::force_capture
   2:     0x7fd4ff58c3eb - std[98e825b980ace71a]::panicking::update_hook::<alloc[b62ea9019244d580]::boxed::Box<rustc_driver_impl[793884a437c970ce]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7fd500586a62 - std[98e825b980ace71a]::panicking::panic_with_hook
   4:     0x7fd50056947a - std[98e825b980ace71a]::panicking::panic_handler::{closure#0}
   5:     0x7fd500560179 - std[98e825b980ace71a]::sys::backtrace::__rust_end_short_backtrace::<std[98e825b980ace71a]::panicking::panic_handler::{closure#0}, !>
   6:     0x7fd50056aead - __rustc[a9b4a1fa1acd65d2]::rust_begin_unwind
   7:     0x7fd4fd2d621c - core[c0e9ef583ed961cc]::panicking::panic_fmt
   8:     0x7fd4fcc26de2 - core[c0e9ef583ed961cc]::panicking::panic
   9:     0x7fd4fd27e379 - core[c0e9ef583ed961cc]::option::unwrap_failed
  10:     0x7fd5019d38ec - <rustc_const_eval[45bdc275d819eb8d]::interpret::eval_context::InterpCx<rustc_const_eval[45bdc275d819eb8d]::const_eval::dummy_machine::DummyMachine>>::read_discriminant::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy>
  11:     0x7fd5019d044a - <rustc_mir_dataflow[36cdc4fee7855ab3]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#1}>
  12:     0x7fd5019d0601 - <rustc_mir_dataflow[36cdc4fee7855ab3]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#1}>
  13:     0x7fd5019d0601 - <rustc_mir_dataflow[36cdc4fee7855ab3]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[45bdc275d819eb8d]::interpret::operand::OpTy, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#0}, <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_constant::{closure#1}>
  14:     0x7fd5019cf898 - <rustc_mir_transform[70b01dc83cb28395]::jump_threading::TOFinder>::process_operand
  15:     0x7fd4fe229881 - <rustc_mir_transform[70b01dc83cb28395]::jump_threading::JumpThreading as rustc_mir_transform[70b01dc83cb28395]::pass_manager::MirPass>::run_pass
  16:     0x7fd500c09522 - rustc_mir_transform[70b01dc83cb28395]::run_optimization_passes
  17:     0x7fd501742915 - rustc_mir_transform[70b01dc83cb28395]::optimized_mir
  18:     0x7fd501742561 - rustc_query_impl[cf13977eb46bb4e5]::query_impl::optimized_mir::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7fd500c5084a - rustc_query_impl[cf13977eb46bb4e5]::execution::try_execute_query::<rustc_middle[ba798c852eab49df]::query::caches::DefIdCache<rustc_middle[ba798c852eab49df]::query::erase::ErasedData<[u8; 8usize]>>, false>
  20:     0x7fd500c4fe8e - rustc_query_impl[cf13977eb46bb4e5]::query_impl::optimized_mir::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7fd5017ff74e - <rustc_metadata[150ae410db238ac5]::rmeta::encoder::EncodeContext>::encode_crate_root
  22:     0x7fd5022d53f1 - <rustc_metadata[150ae410db238ac5]::rmeta::encoder::encode_metadata::{closure#3} as core[c0e9ef583ed961cc]::ops::function::FnOnce<(rustc_middle[ba798c852eab49df]::ty::context::TyCtxt, &std[98e825b980ace71a]::path::Path)>>::call_once
  23:     0x7fd5022d2b94 - rustc_metadata[150ae410db238ac5]::rmeta::encoder::encode_metadata
  24:     0x7fd5019a9f49 - rustc_metadata[150ae410db238ac5]::fs::encode_and_write_metadata
  25:     0x7fd501e11948 - <rustc_interface[6373f0af38dffaf7]::queries::Linker>::codegen_and_build_linker
  26:     0x7fd501e0c6cd - rustc_interface[6373f0af38dffaf7]::interface::run_compiler::<(), rustc_driver_impl[793884a437c970ce]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7fd501df67fe - std[98e825b980ace71a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_with_globals<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_pool_with_globals<rustc_interface[6373f0af38dffaf7]::interface::run_compiler<(), rustc_driver_impl[793884a437c970ce]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  28:     0x7fd501df70a0 - <std[98e825b980ace71a]::thread::lifecycle::spawn_unchecked<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_with_globals<rustc_interface[6373f0af38dffaf7]::util::run_in_thread_pool_with_globals<rustc_interface[6373f0af38dffaf7]::interface::run_compiler<(), rustc_driver_impl[793884a437c970ce]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c0e9ef583ed961cc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7fd501df7f2c - <std[98e825b980ace71a]::sys::thread::unix::Thread>::new::thread_start
  30:     0x7fd4fb8a597a - <unknown>
  31:     0x7fd4fb9292bc - <unknown>
  32:                0x0 - <unknown>


rustc version: 1.96.0-nightly (7e46c5f6f 2026-04-01)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [optimized_mir] optimizing MIR for `point::<impl at /home/facefire/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sec1-0.7.3/src/point.rs:79:1: 81:23>::from_bytes`
end of query stack

Workaround:

rustup toolchain install nightly-2025-11-14
rustup override set nightly-2025-11-14

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 reproducing the panic while compiling sec1 0.7.3 with the reported nightly toolchain and flags. Inspect compiler/rustc_const_eval/src/interpret/discriminant.rs:128 alongside the jump-threading call path shown in the backtrace, and use sec1/src/point.rs:79-81 as the triggering input. Done means the compiler no longer panics on this compilation and the regression is covered by an appropriate compiler test.

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
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.