rust-lang / rust-lang/rust

[ICE]: term_kind: index out of bounds

Open
#159,561 1 comment 0 reactions 1 assignee View on GitHub

@malezjaa is already working on this.

Since Sep 14, 2026.

C-bug E-needs-test F-generic_const_exprs I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]
fn new<const N: usize>()
where
    [(); N * 1]:,
{
}

fn test<const N: usize>()
where
    [(); N - usize::MAX * 1]:,
{
    new
}

original:

#![feature(generic_const_exprs)]
fn new<const N: usize>()
where
    [(); N * 1]: {}
    
    
fn test<const N: usize>()
where
    [(); N - usize::MAX * 1]:,
{
    new
}

fn main() {}

Version information

rustc 1.99.0-nightly (c7d7da342 2026-07-19)
binary: rustc
commit-hash: c7d7da3428c0e8b261e1ce1687e7228cf053cc62
commit-date: 2026-07-19
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:
https://github.com/rust-lang/rust/blob/c7d7da3428c0e8b261e1ce1687e7228cf053cc62/compiler/rustc_type_ir/src/term_kind.rs#L246-L258

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

Program output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.V9VWQjeM5YHh/rustc_testrunner_tmpdir_reporting.f8g9LrITVseG/mvce.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

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


thread 'rustc' (1387308) panicked at /rustc-dev/c7d7da3428c0e8b261e1ce1687e7228cf053cc62/compiler/rustc_type_ir/src/term_kind.rs:252:19:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7fc2fdae2346 - <<std[bb656dee0c1a7164]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[cf8fb3d9e41ef217]::fmt::Display>::fmt
   1:     0x7fc2fe20a310 - core[cf8fb3d9e41ef217]::fmt::write
   2:     0x7fc2fdaf75ac - <std[bb656dee0c1a7164]::sys::stdio::unix::Stderr as core[cf8fb3d9e41ef217]::io::write::Write>::write_fmt
   3:     0x7fc2fdab3fda - std[bb656dee0c1a7164]::panicking::default_hook::{closure#0}
   4:     0x7fc2fdad4a73 - std[bb656dee0c1a7164]::panicking::default_hook
   5:     0x7fc2fca8947b - std[bb656dee0c1a7164]::panicking::update_hook::<alloc[3446759d461fd26]::boxed::Box<rustc_driver_impl[a9408d480ad75656]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fc2fdad4f12 - std[bb656dee0c1a7164]::panicking::panic_with_hook
   7:     0x7fc2fdab4092 - std[bb656dee0c1a7164]::panicking::panic_handler::{closure#0}
   8:     0x7fc2fdaac099 - std[bb656dee0c1a7164]::sys::backtrace::__rust_end_short_backtrace::<std[bb656dee0c1a7164]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fc2fdab59ed - __rustc[2cdb6cc0f92420]::rust_begin_unwind
  10:     0x7fc2faa391dc - core[cf8fb3d9e41ef217]::panicking::panic_fmt
  11:     0x7fc2fa77b6d9 - core[cf8fb3d9e41ef217]::panicking::panic_bounds_check
  12:     0x7fc30034b220 - <&rustc_middle[1b51c4dae9648f9a]::ty::list::RawList<(), rustc_middle[1b51c4dae9648f9a]::ty::generic_args::GenericArg> as rustc_type_ir[265bd1e63db516e4]::inherent::GenericArgs<rustc_middle[1b51c4dae9648f9a]::ty::context::TyCtxt>>::type_at.cold
  13:     0x7fc2fd8db59a - <rustc_trait_selection[1d6ffb784f11fbdc]::traits::wf::WfPredicates>::add_wf_preds_for_inherent_projection
  14:     0x7fc2feb2a386 - <rustc_trait_selection[1d6ffb784f11fbdc]::traits::wf::WfPredicates as rustc_type_ir[265bd1e63db516e4]::visit::TypeVisitor<rustc_middle[1b51c4dae9648f9a]::ty::context::TyCtxt>>::visit_const
  15:     0x7fc2fe8bee7c - <rustc_trait_selection[1d6ffb784f11fbdc]::traits::fulfill::FulfillProcessor as rustc_data_structures[cc1c0a08c9af2296]::obligation_forest::ObligationProcessor>::process_obligation
  16:     0x7fc2fe205c91 - <rustc_data_structures[cc1c0a08c9af2296]::obligation_forest::ObligationForest<rustc_trait_selection[1d6ffb784f11fbdc]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[1d6ffb784f11fbdc]::traits::fulfill::FulfillProcessor>
  17:     0x7fc2fe58cb99 - <rustc_hir_typeck[d340f8d6c940519f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  18:     0x7fc2fe596bec - <rustc_hir_typeck[d340f8d6c940519f]::fn_ctxt::FnCtxt>::check_expr_block
  19:     0x7fc2fe58c5ce - <rustc_hir_typeck[d340f8d6c940519f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x7fc2fe5b61c6 - rustc_hir_typeck[d340f8d6c940519f]::check::check_fn
  21:     0x7fc2ff425ee7 - rustc_hir_typeck[d340f8d6c940519f]::typeck_with_inspect::{closure#0}
  22:     0x7fc2ff424670 - rustc_query_impl[91105c57d45a8e7d]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7fc2fe651869 - rustc_query_impl[91105c57d45a8e7d]::execution::try_execute_query::<rustc_data_structures[cc1c0a08c9af2296]::vec_cache::VecCache<rustc_span[3e8afa6d2baecbb6]::def_id::LocalDefId, rustc_middle[1b51c4dae9648f9a]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[1b51c4dae9648f9a]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7fc2fe6512c3 - rustc_query_impl[91105c57d45a8e7d]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7fc2fe65465e - <rustc_middle[1b51c4dae9648f9a]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[da5de8c042b7d03e]::check_crate::{closure#1}>::{closure#0}
  26:     0x7fc2fe653f5e - rustc_hir_analysis[da5de8c042b7d03e]::check_crate
  27:     0x7fc2fe64df75 - rustc_interface[bd87170b5770ef6e]::passes::analysis
  28:     0x7fc2ff3ad3c7 - rustc_query_impl[91105c57d45a8e7d]::execution::try_execute_query::<rustc_middle[1b51c4dae9648f9a]::query::caches::SingleCache<rustc_middle[1b51c4dae9648f9a]::query::erase::ErasedData<[u8; 0usize]>>, false>
  29:     0x7fc2ff3ad0a9 - rustc_query_impl[91105c57d45a8e7d]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7fc2ff3d0b8d - rustc_interface[bd87170b5770ef6e]::interface::run_compiler::<(), rustc_driver_impl[a9408d480ad75656]::run_compiler::{closure#0}>::{closure#2}
  31:     0x7fc2ff3764a4 - std[bb656dee0c1a7164]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_with_globals<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_pool_with_globals<rustc_interface[bd87170b5770ef6e]::interface::run_compiler<(), rustc_driver_impl[a9408d480ad75656]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7fc2ff376273 - <std[bb656dee0c1a7164]::thread::lifecycle::spawn_unchecked<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_with_globals<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_pool_with_globals<rustc_interface[bd87170b5770ef6e]::interface::run_compiler<(), rustc_driver_impl[a9408d480ad75656]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[cf8fb3d9e41ef217]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fc2ff381048 - <std[bb656dee0c1a7164]::sys::thread::unix::Thread>::new::thread_start
  34:     0x7fc2f8a97739 - <unknown>
  35:     0x7fc2f8b1bedc - <unknown>
  36:                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.99.0-nightly (c7d7da342 2026-07-19) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck_root] type-checking `test`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-generic_const_exprs

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.