rust-lang / rust-lang/rust

[ICE]: infer: `index out of bounds: the len is 0 but the index is 0`

Open
#161,545 1 comment 0 reactions 1 assignee View on GitHub

@TaKO8Ki is already working on this.

Since Sep 8, 2026.

C-bug F-generic_const_exprs F-supertrait_item_shadowing I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

#![feature(supertrait_item_shadowing)]
#![feature(generic_const_exprs)]
trait E<'e> {
    type As;
}
trait F<'a>: E<'a> + for<'e> E<'e> {}

struct G<T>
where
    T: F<'e, As: E>,
{
    X: T,
}

original:

#![feature(supertrait_item_shadowing)]
#![feature(generic_const_exprs)]
trait E<'e> {
    type As;
}
trait F<'a>: E<'a> + for<'e> E<'e> {}

struct G<T>
where
    T: F<'e, As: E>,
{
    X: T,
}

fn main() {}

Version information

rustc 1.100.0-nightly (b0ca9c712 2026-08-22)
binary: rustc
commit-hash: b0ca9c712455d865c3bf0bf5325a3e79677a2d97
commit-date: 2026-08-22
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/b0ca9c712455d865c3bf0bf5325a3e79677a2d97/compiler/rustc_infer/src/infer/mod.rs#L1498-L1510

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

Program output

error[E0261]: use of undeclared lifetime name `'e`
  --> /tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:10:10
   |
10 |     T: F<'e, As: E>,
   |          ^^ undeclared lifetime
   |
   = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'e` lifetime
   |
10 |     T: for<'e> F<'e, As: E>,
   |        +++++++
help: consider making the bound lifetime-generic with a new `'e` lifetime
   |
10 |     for<'e> T: F<'e, As: E>,
   |     +++++++
help: consider introducing lifetime `'e` here
   |
 8 | struct G<'e, T>
   |          +++

error[E0106]: missing lifetime specifier
  --> /tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:10:18
   |
10 |     T: F<'e, As: E>,
   |                  ^ expected named lifetime parameter
   |
help: consider making the bound lifetime-generic with a new `'a` lifetime
   |
10 |     T: F<'e, As: for<'a> E<'a>>,
   |                  +++++++  ++++
help: consider making the bound lifetime-generic with a new `'a` lifetime
   |
10 |     T: for<'a> F<'e, As: E<'a>>,
   |        +++++++            ++++
help: consider making the bound lifetime-generic with a new `'a` lifetime
   |
10 |     for<'a> T: F<'e, As: E<'a>>,
   |     +++++++               ++++
help: consider introducing a named lifetime parameter
   |
 8 ~ struct G<'a, T>
 9 | where
10 ~     T: F<'e, As: E<'a>>,
   |

warning: `feature(generic_const_exprs)` is not supported with the next-generation trait solver
 --> /tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `-Znext-solver=globally` is currently enabled by default for testing
  = note: reverted the setting to `-Znext-solver=coherence` for this crate
  = note: the currently stable trait solver will be used for this crate
  = note: see issues #160895 <https://github.com/rust-lang/rust/issues/160895> for more information

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:2:12
  |
2 | #![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.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs`

error[E0283]: type annotations needed: cannot satisfy `Self: E<'a>`
 --> /tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:6:14
  |
6 | trait F<'a>: E<'a> + for<'e> E<'e> {}
  |              ^^^^^
  |
note: multiple `impl`s or `where` clauses satisfying `Self: E<'a>` found
 --> /tmp/icemaker_global_tempdir.eqgShu82wjy8/rustc_testrunner_tmpdir_reporting.MZP3wCkwT6bQ/mvce.rs:6:14
  |
6 | trait F<'a>: E<'a> + for<'e> E<'e> {}
  |              ^^^^^   ^^^^^^^^^^^^^


thread 'rustc' (4014998) panicked at /rustc-dev/b0ca9c712455d865c3bf0bf5325a3e79677a2d97/compiler/rustc_infer/src/infer/mod.rs:1504:26:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f38f11fc246 - <<std[29541300fb290a5d]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[460910d47b72e8ee]::fmt::Display>::fmt
   1:     0x7f38f180b023 - core[460910d47b72e8ee]::fmt::write
   2:     0x7f38f121172c - <std[29541300fb290a5d]::sys::stdio::unix::Stderr as core[460910d47b72e8ee]::io::write::Write>::write_fmt
   3:     0x7f38f11cf61a - std[29541300fb290a5d]::panicking::default_hook::{closure#0}
   4:     0x7f38f11f04a3 - std[29541300fb290a5d]::panicking::default_hook
   5:     0x7f38f01a89aa - std[29541300fb290a5d]::panicking::update_hook::<alloc[e06df03e17637ff3]::boxed::Box<rustc_driver_impl[56abbf040ce8585c]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f38f11f0942 - std[29541300fb290a5d]::panicking::panic_with_hook
   7:     0x7f38f11cf6d2 - std[29541300fb290a5d]::panicking::panic_handler::{closure#0}
   8:     0x7f38f11c6509 - std[29541300fb290a5d]::sys::backtrace::__rust_end_short_backtrace::<std[29541300fb290a5d]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f38f11d100d - __rustc[764f694db36a77d7]::rust_begin_unwind
  10:     0x7f38edfaae3c - core[460910d47b72e8ee]::panicking::panic_fmt
  11:     0x7f38eea3647a - core[460910d47b72e8ee]::panicking::panic_bounds_check
  12:     0x7f38f396dccd - <<rustc_infer[775c003696668d9d]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars as rustc_middle[9d9ea3708d6e93f5]::ty::fold::BoundVarReplacerDelegate>::replace_region.cold
  13:     0x7f38f279374e - <&rustc_middle[9d9ea3708d6e93f5]::ty::list::RawList<(), rustc_middle[9d9ea3708d6e93f5]::ty::generic_args::GenericArg> as rustc_type_ir[c55ed8222f6694be]::fold::TypeFoldable<rustc_middle[9d9ea3708d6e93f5]::ty::context::TyCtxt>>::fold_with::<rustc_middle[9d9ea3708d6e93f5]::ty::fold::BoundVarReplacer<<rustc_infer[775c003696668d9d]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars>>
  14:     0x7f38f279467a - <rustc_middle[9d9ea3708d6e93f5]::ty::fold::BoundVarReplacer<<rustc_infer[775c003696668d9d]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars> as rustc_type_ir[c55ed8222f6694be]::fold::TypeFolder<rustc_middle[9d9ea3708d6e93f5]::ty::context::TyCtxt>>::fold_ty
  15:     0x7f38ed8c1db4 - <rustc_trait_selection[6d6a1773eb45fa07]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  16:     0x7f38f1d6ed27 - <rustc_trait_selection[6d6a1773eb45fa07]::traits::select::SelectionContext>::poly_select::{closure#0}
  17:     0x7f38f1d5b0b5 - rustc_trait_selection[6d6a1773eb45fa07]::traits::project::opt_normalize_projection_term
  18:     0x7f38f1d63355 - <rustc_trait_selection[6d6a1773eb45fa07]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[c55ed8222f6694be]::fold::TypeFolder<rustc_middle[9d9ea3708d6e93f5]::ty::context::TyCtxt>>::fold_ty
  19:     0x7f38f1d61c93 - <&rustc_middle[9d9ea3708d6e93f5]::ty::list::RawList<(), rustc_middle[9d9ea3708d6e93f5]::ty::generic_args::GenericArg> as rustc_type_ir[c55ed8222f6694be]::fold::TypeFoldable<rustc_middle[9d9ea3708d6e93f5]::ty::context::TyCtxt>>::fold_with::<rustc_trait_selection[6d6a1773eb45fa07]::traits::normalize::AssocTypeNormalizer>
  20:     0x7f38f27c5d27 - <rustc_middle[9d9ea3708d6e93f5]::ty::predicate::Clause as rustc_type_ir[c55ed8222f6694be]::fold::TypeFoldable<rustc_middle[9d9ea3708d6e93f5]::ty::context::TyCtxt>>::fold_with::<rustc_trait_selection[6d6a1773eb45fa07]::traits::normalize::AssocTypeNormalizer>
  21:     0x7f38f27c527e - <rustc_infer[775c003696668d9d]::infer::at::At as rustc_trait_selection[6d6a1773eb45fa07]::traits::normalize::NormalizeExt>::normalize::<alloc[e06df03e17637ff3]::vec::Vec<rustc_middle[9d9ea3708d6e93f5]::ty::predicate::Clause>>
  22:     0x7f38f2d28322 - rustc_trait_selection[6d6a1773eb45fa07]::traits::do_normalize_clauses
  23:     0x7f38f1e536c0 - rustc_trait_selection[6d6a1773eb45fa07]::traits::normalize_param_env_or_error
  24:     0x7f38f1e5e8ea - rustc_ty_utils[a79d7b537cc149b5]::ty::param_env
  25:     0x7f38f186667d - rustc_query_impl[a298bd9aef25de82]::execution::try_execute_query::<rustc_middle[9d9ea3708d6e93f5]::query::caches::DefIdCache<rustc_middle[9d9ea3708d6e93f5]::query::erase::ErasedData<[u8; 8usize]>>, false>
  26:     0x7f38f18662e3 - rustc_query_impl[a298bd9aef25de82]::query_vtables::param_env::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f38f2097a03 - rustc_hir_analysis[30f31704cfa60f6c]::check::wfcheck::check_type_defn
  28:     0x7f38f23ff1f2 - rustc_hir_analysis[30f31704cfa60f6c]::check::check::check_item_type
  29:     0x7f38f23f81a6 - rustc_hir_analysis[30f31704cfa60f6c]::check::wfcheck::check_well_formed
  30:     0x7f38f23f8187 - rustc_query_impl[a298bd9aef25de82]::query_vtables::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  31:     0x7f38f23f77df - rustc_query_impl[a298bd9aef25de82]::execution::try_execute_query::<rustc_data_structures[ce2d1b2e5f4b9540]::vec_cache::VecCache<rustc_span[7b0e571682104a6f]::def_id::LocalDefId, rustc_middle[9d9ea3708d6e93f5]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[9d9ea3708d6e93f5]::dep_graph::graph::DepNodeIndex>, false>
  32:     0x7f38f23f7571 - rustc_query_impl[a298bd9aef25de82]::query_vtables::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f38f23f3420 - rustc_hir_analysis[30f31704cfa60f6c]::check::wfcheck::check_type_wf
  34:     0x7f38f23f331b - rustc_query_impl[a298bd9aef25de82]::query_vtables::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7f38f2a11c49 - rustc_query_impl[a298bd9aef25de82]::execution::try_execute_query::<rustc_middle[9d9ea3708d6e93f5]::query::caches::SingleCache<rustc_middle[9d9ea3708d6e93f5]::query::erase::ErasedData<[u8; 1usize]>>, false>
  36:     0x7f38f2a11a2d - rustc_query_impl[a298bd9aef25de82]::query_vtables::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f38f2078c64 - rustc_hir_analysis[30f31704cfa60f6c]::check_crate
  38:     0x7f38f232c0ba - rustc_interface[473d810ada35544b]::passes::analysis
  39:     0x7f38f2a1354a - rustc_query_impl[a298bd9aef25de82]::execution::try_execute_query::<rustc_middle[9d9ea3708d6e93f5]::query::caches::SingleCache<rustc_middle[9d9ea3708d6e93f5]::query::erase::ErasedData<[u8; 0usize]>>, false>
  40:     0x7f38f2a132eb - rustc_query_impl[a298bd9aef25de82]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  41:     0x7f38f2b85c6b - rustc_interface[473d810ada35544b]::interface::run_compiler::<(), rustc_driver_impl[56abbf040ce8585c]::run_compiler::{closure#0}>::{closure#2}
  42:     0x7f38f2bd7582 - std[29541300fb290a5d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[473d810ada35544b]::util::run_in_thread_with_globals<rustc_interface[473d810ada35544b]::util::run_in_thread_pool_with_globals<rustc_interface[473d810ada35544b]::interface::run_compiler<(), rustc_driver_impl[56abbf040ce8585c]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  43:     0x7f38f2bd732d - <std[29541300fb290a5d]::thread::lifecycle::spawn_unchecked<rustc_interface[473d810ada35544b]::util::run_in_thread_with_globals<rustc_interface[473d810ada35544b]::util::run_in_thread_pool_with_globals<rustc_interface[473d810ada35544b]::interface::run_compiler<(), rustc_driver_impl[56abbf040ce8585c]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[460910d47b72e8ee]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f38f2bd4d87 - <std[29541300fb290a5d]::sys::thread::unix::Thread>::new::thread_start
  45:     0x7f38ebe97739 - <unknown>
  46:     0x7f38ebf1bedc - <unknown>
  47:                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.100.0-nightly (b0ca9c712 2026-08-22) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [param_env] computing normalized predicates of `G`
#1 [check_well_formed] checking that `G` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 2 warnings emitted

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

@rustbot label +F-supertrait_item_shadowing +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.