rust-lang / rust-lang/rust

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

Open
#153,356 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-non_lifetime_binders I-ICE needs-triage T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(non_lifetime_binders)]

impl<'b, Itemm> IntoIterator for IterRef
where
    for<'a, T, Item, IntoIter> &'a T:,
    for<'a, T, Item, IntoIter> &'a T: IntoIterator<Item = Item, IntoIter = IntoIter>,
{
    fn into_iter(self) -> Self::IntoIter {}
}

original:

#![feature(non_lifetime_binders)]

impl<'b, Itemm> IntoIterator for IterRef<IntoIter = Itemm>
where
    for<'a, T, Item, IntoIter> &'a T:,
    for<'a, T, Item, IntoIter> &'a T: IntoIterator<Item = Item, IntoIter = IntoIter>,
{
    fn into_iter(self) -> Self::IntoIter {}
}

fn main() {}

Version information

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

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

error[E0425]: cannot find type `IterRef` in this scope
 --> /tmp/icemaker_global_tempdir.ScxgzaNVLgAH/rustc_testrunner_tmpdir_reporting.lDJFySxN2Gpp/mvce.rs:3:34
  |
3 | impl<'b, Itemm> IntoIterator for IterRef
  |                                  ^^^^^^^ not found in this scope

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

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


thread 'rustc' (512111) panicked at /rust/deps/ena-0.14.4/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f0ce9762aab - <<std[76599d2169901dc8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[d5ffb84325ed5c2a]::fmt::Display>::fmt
   1:     0x7f0ce9e228c8 - core[d5ffb84325ed5c2a]::fmt::write
   2:     0x7f0ce9779ab6 - <std[76599d2169901dc8]::sys::stdio::unix::Stderr as std[76599d2169901dc8]::io::Write>::write_fmt
   3:     0x7f0ce9738b88 - std[76599d2169901dc8]::panicking::default_hook::{closure#0}
   4:     0x7f0ce9755f13 - std[76599d2169901dc8]::panicking::default_hook
   5:     0x7f0ce87424cc - std[76599d2169901dc8]::panicking::update_hook::<alloc[f847baa7d3d2ac55]::boxed::Box<rustc_driver_impl[ffd722fd6c32666a]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0ce97561f2 - std[76599d2169901dc8]::panicking::panic_with_hook
   7:     0x7f0ce9738c48 - std[76599d2169901dc8]::panicking::panic_handler::{closure#0}
   8:     0x7f0ce972f979 - std[76599d2169901dc8]::sys::backtrace::__rust_end_short_backtrace::<std[76599d2169901dc8]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f0ce973a6ad - __rustc[7dea9537d06e225e]::rust_begin_unwind
  10:     0x7f0ce631975c - core[d5ffb84325ed5c2a]::panicking::panic_fmt
  11:     0x7f0ce66fa982 - core[d5ffb84325ed5c2a]::panicking::panic_bounds_check
  12:     0x7f0cea84cc10 - <rustc_trait_selection[502c21a12406236f]::solve::delegate::SolverDelegate as rustc_next_trait_solver[beb9dc5464000fde]::delegate::SolverDelegate>::compute_goal_fast_path
  13:     0x7f0cea84e71c - <rustc_trait_selection[502c21a12406236f]::solve::fulfill::FulfillmentCtxt<rustc_infer[a106829e2b559cfc]::traits::engine::ScrubbedTraitError> as rustc_infer[a106829e2b559cfc]::traits::engine::TraitEngine<rustc_infer[a106829e2b559cfc]::traits::engine::ScrubbedTraitError>>::evaluate_obligations_error_on_ambiguity
  14:     0x7f0ce9edc625 - rustc_trait_selection[502c21a12406236f]::traits::type_known_to_meet_bound_modulo_regions
  15:     0x7f0ce9edb292 - rustc_ty_utils[23782f25fc8ac972]::common_traits::is_copy_raw
  16:     0x7f0ce9edae87 - rustc_query_impl[89f9236b2ac04da0]::query_impl::is_copy_raw::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7f0cea3bcce7 - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::DefaultCache<rustc_middle[7c9cbe436035c5a4]::ty::PseudoCanonicalInput<rustc_middle[7c9cbe436035c5a4]::ty::Ty>, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 1usize]>>, false>
  18:     0x7f0cea3bc8c9 - rustc_query_impl[89f9236b2ac04da0]::query_impl::is_copy_raw::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7f0cea3be4f0 - rustc_ty_utils[23782f25fc8ac972]::needs_drop::needs_drop_raw
  20:     0x7f0cea3bde67 - rustc_query_impl[89f9236b2ac04da0]::query_impl::needs_drop_raw::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f0cea3bcc59 - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::DefaultCache<rustc_middle[7c9cbe436035c5a4]::ty::PseudoCanonicalInput<rustc_middle[7c9cbe436035c5a4]::ty::Ty>, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 1usize]>>, false>
  22:     0x7f0cea3bc839 - rustc_query_impl[89f9236b2ac04da0]::query_impl::needs_drop_raw::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f0ce6715c96 - <rustc_mir_transform[c7b522523fe3a5eb]::elaborate_drops::ElaborateDrops as rustc_mir_transform[c7b522523fe3a5eb]::pass_manager::MirPass>::run_pass
  24:     0x7f0ce9e0ce6a - rustc_mir_transform[c7b522523fe3a5eb]::run_analysis_to_runtime_passes
  25:     0x7f0ceac1c5c4 - rustc_mir_transform[c7b522523fe3a5eb]::mir_drops_elaborated_and_const_checked
  26:     0x7f0ceac1c021 - rustc_query_impl[89f9236b2ac04da0]::query_impl::mir_drops_elaborated_and_const_checked::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7f0ce9f6d18a - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_data_structures[79f5f180de225010]::vec_cache::VecCache<rustc_span[8a71b77c74bc13cb]::def_id::LocalDefId, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[7c9cbe436035c5a4]::dep_graph::graph::DepNodeIndex>, false>
  28:     0x7f0ce9f6c8c3 - rustc_query_impl[89f9236b2ac04da0]::query_impl::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f0ce9f6ac48 - <rustc_middle[7c9cbe436035c5a4]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[400bc27e64bfd912]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  30:     0x7f0ce9f6a02f - rustc_interface[400bc27e64bfd912]::passes::analysis
  31:     0x7f0ceb03175c - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::SingleCache<rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 0usize]>>, false>
  32:     0x7f0ceb0314bb - rustc_query_impl[89f9236b2ac04da0]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f0ceafeda2d - rustc_interface[400bc27e64bfd912]::interface::run_compiler::<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}
  34:     0x7f0ceafd20be - std[76599d2169901dc8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[400bc27e64bfd912]::util::run_in_thread_with_globals<rustc_interface[400bc27e64bfd912]::util::run_in_thread_pool_with_globals<rustc_interface[400bc27e64bfd912]::interface::run_compiler<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7f0ceafd2720 - <std[76599d2169901dc8]::thread::lifecycle::spawn_unchecked<rustc_interface[400bc27e64bfd912]::util::run_in_thread_with_globals<rustc_interface[400bc27e64bfd912]::util::run_in_thread_pool_with_globals<rustc_interface[400bc27e64bfd912]::interface::run_compiler<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d5ffb84325ed5c2a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7f0ceafd35ac - <std[76599d2169901dc8]::sys::thread::unix::Thread>::new::thread_start
  37:     0x7f0ce4aa598b - <unknown>
  38:     0x7f0ce4b29a0c - <unknown>
  39:                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 (d2218f5f5 2026-03-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [is_copy_raw] computing whether `_` is `Copy`
#1 [needs_drop_raw] computing whether `_` needs drop
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `<impl at /tmp/icemaker_global_tempdir.ScxgzaNVLgAH/rustc_testrunner_tmpdir_reporting.lDJFySxN2Gpp/mvce.rs:3:1: 6:86>::into_iter`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

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

@rustbot label +F-non_lifetime_binders +WG-trait-system-refactor

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 compiling the reduced Rust program with -Znext-solver=globally and compare the query stack around rustc_trait_selection::solve::delegate::compute_goal_fast_path. Trace the snapshot_vec panic through trait solving and drop elaboration; done means the reproducer no longer causes an internal compiler error while reporting its ordinary diagnostics.

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
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.