rust-lang / rust-lang/rust

[ICE]: rustc panicked at compiler/rustc_middle/src/ty/generics.rs:238:29

Open
#159,424 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-eval C-bug F-generic_const_exprs I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

Code
//rustc
#![feature(generic_const_exprs)]
const KEY_LEN: usize = 16;
struct Test(
    [u8;const { std::mem::align_of::<fn(&'static [u8; KEY_LEN]) -> [[u8; KEY_LEN]; 2]>() }],
);
fn main() {}
Meta

rustc --version --verbose:

rustc 1.99.0-nightly (3d50c25bc 2026-07-16)
binary: rustc
commit-hash: 3d50c25bc66853bf0ad205529d0f305a1d841b5e
commit-date: 2026-07-16
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
Error output
<output>
Backtrace

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> ./bug.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default


thread 'rustc' (3948694) panicked at /rustc-dev/3d50c25bc66853bf0ad205529d0f305a1d841b5e/compiler/rustc_middle/src/ty/generics.rs:238:29:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7fe84b629ac6 - <<std[85685cc41b6aa0cb]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[87bdcaa552bbd21b]::fmt::Display>::fmt
   1:     0x7fe84bc0f108 - core[87bdcaa552bbd21b]::fmt::write
   2:     0x7fe84b63ed2c - <std[85685cc41b6aa0cb]::sys::stdio::unix::Stderr as core[87bdcaa552bbd21b]::io::write::Write>::write_fmt
   3:     0x7fe84b5fb74a - std[85685cc41b6aa0cb]::panicking::default_hook::{closure#0}
   4:     0x7fe84b61c1e3 - std[85685cc41b6aa0cb]::panicking::default_hook
   5:     0x7fe84a5dae1b - std[85685cc41b6aa0cb]::panicking::update_hook::<alloc[1c70cbec17740dd6]::boxed::Box<rustc_driver_impl[3655cec28c8e3dd4]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fe84b61c682 - std[85685cc41b6aa0cb]::panicking::panic_with_hook
   7:     0x7fe84b5fb802 - std[85685cc41b6aa0cb]::panicking::panic_handler::{closure#0}
   8:     0x7fe84b5f3ef9 - std[85685cc41b6aa0cb]::sys::backtrace::__rust_end_short_backtrace::<std[85685cc41b6aa0cb]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fe84b5fd15d - __rustc[ae31d3f5d92751]::rust_begin_unwind
  10:     0x7fe8482c589c - core[87bdcaa552bbd21b]::panicking::panic_fmt
  11:     0x7fe8484c68d9 - core[87bdcaa552bbd21b]::panicking::panic_bounds_check
  12:     0x7fe84d700968 - <rustc_middle[8ffa8a2cfff5a29b]::ty::generics::Generics>::param_at.cold
  13:     0x7fe84868f61e - <rustc_middle[8ffa8a2cfff5a29b]::ty::generics::Generics>::type_param
  14:     0x7fe84b4346d7 - <rustc_trait_selection[473f3e6928bcdffc]::error_reporting::TypeErrCtxt>::construct_generic_bound_failure
  15:     0x7fe84a30223e - <rustc_borrowck[1278ed6949740ead]::MirBorrowckCtxt>::report_region_errors
  16:     0x7fe8484ef93e - rustc_borrowck[1278ed6949740ead]::borrowck_check_region_constraints
  17:     0x7fe84d02e1eb - <rustc_borrowck[1278ed6949740ead]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  18:     0x7fe84c1dd219 - rustc_borrowck[1278ed6949740ead]::mir_borrowck
  19:     0x7fe84c1dcfe5 - rustc_query_impl[ce396915e304eaeb]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7fe84c1d9029 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_data_structures[755bacfd33cc47ea]::vec_cache::VecCache<rustc_span[56fa0836cabb6bc5]::def_id::LocalDefId, rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[8ffa8a2cfff5a29b]::dep_graph::graph::DepNodeIndex>, false>
  21:     0x7fe84c1d66d3 - rustc_query_impl[ce396915e304eaeb]::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7fe84c0da3ea - rustc_mir_transform[3b214a7bf95059fd]::mir_drops_elaborated_and_const_checked
  23:     0x7fe84c0d9959 - rustc_query_impl[ce396915e304eaeb]::query_impl::mir_drops_elaborated_and_const_checked::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7fe84c1d9029 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_data_structures[755bacfd33cc47ea]::vec_cache::VecCache<rustc_span[56fa0836cabb6bc5]::def_id::LocalDefId, rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[8ffa8a2cfff5a29b]::dep_graph::graph::DepNodeIndex>, false>
  25:     0x7fe84c1d8843 - rustc_query_impl[ce396915e304eaeb]::query_impl::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7fe84c9f41b6 - rustc_mir_transform[3b214a7bf95059fd]::mir_for_ctfe
  27:     0x7fe84c9f3adf - rustc_query_impl[ce396915e304eaeb]::query_impl::mir_for_ctfe::invoke_provider_fn::__rust_begin_short_backtrace
  28:     0x7fe84bc4804d - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_middle[8ffa8a2cfff5a29b]::query::caches::DefIdCache<rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 8usize]>>, false>
  29:     0x7fe84cbfa54e - rustc_query_impl[ce396915e304eaeb]::query_impl::mir_for_ctfe::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7fe84cbf9f10 - <rustc_const_eval[fce0b70b07f4709e]::interpret::eval_context::InterpCx<rustc_const_eval[fce0b70b07f4709e]::const_eval::machine::CompileTimeMachine>>::load_mir
  31:     0x7fe84cbfb64d - rustc_const_eval[fce0b70b07f4709e]::const_eval::eval_queries::eval_to_allocation_raw_provider
  32:     0x7fe84cbfae96 - rustc_query_impl[ce396915e304eaeb]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0x7fe84cbf6867 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_middle[8ffa8a2cfff5a29b]::query::caches::DefaultCache<rustc_middle[8ffa8a2cfff5a29b]::ty::PseudoCanonicalInput<rustc_middle[8ffa8a2cfff5a29b]::mir::interpret::GlobalId>, rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 24usize]>>, false>
  34:     0x7fe84cbf5cbf - rustc_query_impl[ce396915e304eaeb]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7fe84cbf3a6d - rustc_const_eval[fce0b70b07f4709e]::const_eval::valtrees::eval_to_valtree
  36:     0x7fe84cbf3826 - <rustc_const_eval[fce0b70b07f4709e]::provide::{closure#0} as core[87bdcaa552bbd21b]::ops::function::FnOnce<(rustc_middle[8ffa8a2cfff5a29b]::ty::context::TyCtxt, rustc_middle[8ffa8a2cfff5a29b]::ty::PseudoCanonicalInput<rustc_middle[8ffa8a2cfff5a29b]::mir::interpret::GlobalId>)>>::call_once
  37:     0x7fe84cbf37d8 - rustc_query_impl[ce396915e304eaeb]::query_impl::eval_to_valtree::invoke_provider_fn::__rust_begin_short_backtrace
  38:     0x7fe84cbec3e0 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_middle[8ffa8a2cfff5a29b]::query::caches::DefaultCache<rustc_middle[8ffa8a2cfff5a29b]::ty::PseudoCanonicalInput<rustc_middle[8ffa8a2cfff5a29b]::mir::interpret::GlobalId>, rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 16usize]>>, false>
  39:     0x7fe84cbec088 - rustc_query_impl[ce396915e304eaeb]::query_impl::eval_to_valtree::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7fe84c660b69 - <rustc_middle[8ffa8a2cfff5a29b]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  41:     0x7fe84c65c0a7 - rustc_trait_selection[473f3e6928bcdffc]::traits::try_evaluate_const
  42:     0x7fe84d52eebf - rustc_trait_selection[473f3e6928bcdffc]::traits::const_evaluatable::is_const_evaluatable.cold
  43:     0x7fe84c296127 - <rustc_trait_selection[473f3e6928bcdffc]::traits::fulfill::FulfillProcessor as rustc_data_structures[755bacfd33cc47ea]::obligation_forest::ObligationProcessor>::process_obligation
  44:     0x7fe84bc05c51 - <rustc_data_structures[755bacfd33cc47ea]::obligation_forest::ObligationForest<rustc_trait_selection[473f3e6928bcdffc]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[473f3e6928bcdffc]::traits::fulfill::FulfillProcessor>
  45:     0x7fe84c518729 - <rustc_trait_selection[473f3e6928bcdffc]::traits::fulfill::FulfillmentContext<rustc_trait_selection[473f3e6928bcdffc]::traits::FulfillmentError> as rustc_infer[9a0c856dbde06bdb]::traits::engine::TraitEngine<rustc_trait_selection[473f3e6928bcdffc]::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  46:     0x7fe84c504762 - rustc_hir_analysis[b2a787fd366549f1]::check::wfcheck::check_type_defn
  47:     0x7fe84c7a6248 - rustc_hir_analysis[b2a787fd366549f1]::check::check::check_item_type
  48:     0x7fe84c79f29c - rustc_hir_analysis[b2a787fd366549f1]::check::wfcheck::check_well_formed
  49:     0x7fe84c79f273 - rustc_query_impl[ce396915e304eaeb]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  50:     0x7fe84c79e853 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_data_structures[755bacfd33cc47ea]::vec_cache::VecCache<rustc_span[56fa0836cabb6bc5]::def_id::LocalDefId, rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[8ffa8a2cfff5a29b]::dep_graph::graph::DepNodeIndex>, false>
  51:     0x7fe84c79e5d3 - rustc_query_impl[ce396915e304eaeb]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  52:     0x7fe84c79b0c6 - rustc_hir_analysis[b2a787fd366549f1]::check::wfcheck::check_type_wf
  53:     0x7fe84c79afcf - rustc_query_impl[ce396915e304eaeb]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  54:     0x7fe84ce02506 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_middle[8ffa8a2cfff5a29b]::query::caches::SingleCache<rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 1usize]>>, false>
  55:     0x7fe84ce022e9 - rustc_query_impl[ce396915e304eaeb]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  56:     0x7fe84c1da864 - rustc_hir_analysis[b2a787fd366549f1]::check_crate
  57:     0x7fe84c1d5775 - rustc_interface[eaa6da338f395277]::passes::analysis
  58:     0x7fe84ce00a87 - rustc_query_impl[ce396915e304eaeb]::execution::try_execute_query::<rustc_middle[8ffa8a2cfff5a29b]::query::caches::SingleCache<rustc_middle[8ffa8a2cfff5a29b]::query::erase::ErasedData<[u8; 0usize]>>, false>
  59:     0x7fe84ce006e9 - rustc_query_impl[ce396915e304eaeb]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  60:     0x7fe84cd9ef5b - rustc_interface[eaa6da338f395277]::interface::run_compiler::<(), rustc_driver_impl[3655cec28c8e3dd4]::run_compiler::{closure#0}>::{closure#1}
  61:     0x7fe84ce0d1fa - std[85685cc41b6aa0cb]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eaa6da338f395277]::util::run_in_thread_with_globals<rustc_interface[eaa6da338f395277]::util::run_in_thread_pool_with_globals<rustc_interface[eaa6da338f395277]::interface::run_compiler<(), rustc_driver_impl[3655cec28c8e3dd4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  62:     0x7fe84ce0cfad - <std[85685cc41b6aa0cb]::thread::lifecycle::spawn_unchecked<rustc_interface[eaa6da338f395277]::util::run_in_thread_with_globals<rustc_interface[eaa6da338f395277]::util::run_in_thread_pool_with_globals<rustc_interface[eaa6da338f395277]::interface::run_compiler<(), rustc_driver_impl[3655cec28c8e3dd4]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[87bdcaa552bbd21b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  63:     0x7fe84ce113d0 - <std[85685cc41b6aa0cb]::sys::thread::unix::Thread>::new::thread_start
  64:     0x7fe84688aaa4 - start_thread
                               at ./nptl/pthread_create.c:447:8
  65:     0x7fe846917c6c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  66:                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/bug/rustc-ice-2026-07-17T06_51_47-3948684.txt` to your bug report

note: rustc 1.99.0-nightly (3d50c25bc 2026-07-16) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `Test::0::{constant#0}`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `Test::0::{constant#0}`
... and 6 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: TypeTestError { type_test: TypeTest from ./bug.rs:4:17: 4:87 (#0)['?1: '?0] ⊢ <const_ty>/#0: '?0 }
  |
  = note: delayed at /rustc-dev/3d50c25bc66853bf0ad205529d0f305a1d841b5e/compiler/rustc_borrowck/src/region_infer/mod.rs:633:31 - disabled 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 `/home/bug/rustc-ice-2026-07-17T06_51_47-3948684.txt` to your bug report

note: rustc 1.99.0-nightly (3d50c25bc 2026-07-16) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

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 with the reproducer in the issue and inspect compiler/rustc_middle/src/ty/generics.rs at line 238, especially Generics::param_at and its callers in rustc_borrowck. Trace how the generic_const_exprs example reaches type checking and const evaluation. Done means this input no longer causes an index-out-of-bounds panic and instead completes or emits a compiler diagnostic.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.