Skip to content

[ICE]: ast validation: index out of bounds: the len is 0 but the index is 18446744073709551615 #152338

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct Clone<T, I> where <>::Item: Clone, <T>::Item = T { ... }

original:

fn foo<I>(x: I) where I: Iterator, <I as T>::Item = T { ... }
// should be
struct Foo<I> where <I as Iterator>::Item: Clone { ... }
// should be
fn foo<I>(x: I) where I: I, Clone: Iterator { ... }

struct Clone<T, I> where <I as Iterator>::Item: Clone, <T>::Item = T { ... }
// should be

Version information

rustc 1.95.0-nightly (13c38730d 2026-02-08)
binary: rustc
commit-hash: 13c38730d981289cc7ae4cc109fd7756bf83ee67
commit-date: 2026-02-08
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

kind: AssocItemConstraintKind::Equality {
term: predicate.rhs_ty.clone().into(),
},
span: ident.span,
});
// Add `<Bar = RhsTy>` to `Foo`.
match &mut assoc_path.segments[len].args {
Some(args) => match args.deref_mut() {
GenericArgs::Parenthesized(_) | GenericArgs::ParenthesizedElided(..) => {
continue;
}
GenericArgs::AngleBracketed(args) => {
args.args.push(arg);

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

Program output

error: generic parameters on `where` clauses are reserved for future use
 --> /tmp/icemaker_global_tempdir.qmMHiDBdDJKL/rustc_testrunner_tmpdir_reporting.cO0d0MlXd2jj/mvce.rs:7:26
  |
7 | struct Clone<T, I> where <>::Item: Clone, <T>::Item = T { ... }
  |                          ^^ currently unsupported

error: expected identifier, found `...`
 --> /tmp/icemaker_global_tempdir.qmMHiDBdDJKL/rustc_testrunner_tmpdir_reporting.cO0d0MlXd2jj/mvce.rs:7:59
  |
7 | struct Clone<T, I> where <>::Item: Clone, <T>::Item = T { ... }
  |        ----- while parsing this struct                    ^^^ expected identifier


thread 'rustc' (3949250) panicked at /rustc-dev/13c38730d981289cc7ae4cc109fd7756bf83ee67/compiler/rustc_ast_passes/src/ast_validation.rs:1865:28:
index out of bounds: the len is 0 but the index is 18446744073709551615
stack backtrace:
   0:     0x7f9d85fbebcb - <<std[bd410f491febadb6]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[2ca3c49344714521]::fmt::Display>::fmt
   1:     0x7f9d8660ecc8 - core[2ca3c49344714521]::fmt::write
   2:     0x7f9d85fd5eb6 - <std[bd410f491febadb6]::sys::stdio::unix::Stderr as std[bd410f491febadb6]::io::Write>::write_fmt
   3:     0x7f9d85f94c08 - std[bd410f491febadb6]::panicking::default_hook::{closure#0}
   4:     0x7f9d85fb1fd3 - std[bd410f491febadb6]::panicking::default_hook
   5:     0x7f9d84f8c9e2 - std[bd410f491febadb6]::panicking::update_hook::<alloc[a248f8e1b1583859]::boxed::Box<rustc_driver_impl[b59eeeb9fc736c31]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f9d85fb22b2 - std[bd410f491febadb6]::panicking::panic_with_hook
   7:     0x7f9d85f94cc8 - std[bd410f491febadb6]::panicking::panic_handler::{closure#0}
   8:     0x7f9d85f89239 - std[bd410f491febadb6]::sys::backtrace::__rust_end_short_backtrace::<std[bd410f491febadb6]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f9d85f9672d - __rustc[25666c693a360600]::rust_begin_unwind
  10:     0x7f9d83191bec - core[2ca3c49344714521]::panicking::panic_fmt
  11:     0x7f9d82e108a2 - core[2ca3c49344714521]::panicking::panic_bounds_check
  12:     0x7f9d86e5af54 - <rustc_ast_passes[2f7337dc52c84f6a]::ast_validation::AstValidator as rustc_ast[e9c4ef51180b6f1a]::visit::Visitor>::visit_generics
  13:     0x7f9d86e61387 - <rustc_ast_passes[2f7337dc52c84f6a]::ast_validation::AstValidator as rustc_ast[e9c4ef51180b6f1a]::visit::Visitor>::visit_item
  14:     0x7f9d86e50ae9 - rustc_interface[923b877a2cdf5a67]::passes::resolver_for_lowering_raw
  15:     0x7f9d86e4fc17 - rustc_query_impl[21826ead98e520a1]::query_impl::resolver_for_lowering_raw::compute_fn::__rust_begin_short_backtrace
  16:     0x7f9d8789279a - rustc_query_system[6518298d71496d73]::query::plumbing::try_execute_query::<rustc_query_impl[21826ead98e520a1]::SemiDynamicQueryDispatcher<rustc_query_system[6518298d71496d73]::query::caches::SingleCache<rustc_middle[3efcf2d0f50fae3f]::query::erase::ErasedData<[u8; 16usize]>>, {rustc_query_impl[21826ead98e520a1]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
  17:     0x7f9d878922fe - rustc_query_impl[21826ead98e520a1]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  18:     0x7f9d879d320f - <rustc_interface[923b877a2cdf5a67]::passes::create_and_enter_global_ctxt<core[2ca3c49344714521]::option::Option<rustc_interface[923b877a2cdf5a67]::queries::Linker>, rustc_driver_impl[b59eeeb9fc736c31]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[2ca3c49344714521]::ops::function::FnOnce<(&rustc_session[45e3122b25e742c0]::session::Session, rustc_middle[3efcf2d0f50fae3f]::ty::context::CurrentGcx, alloc[a248f8e1b1583859]::sync::Arc<rustc_data_structures[ca9174053067dbfd]::jobserver::Proxy>, &std[bd410f491febadb6]::sync::once_lock::OnceLock<rustc_middle[3efcf2d0f50fae3f]::ty::context::GlobalCtxt>, &rustc_data_structures[ca9174053067dbfd]::sync::worker_local::WorkerLocal<rustc_middle[3efcf2d0f50fae3f]::arena::Arena>, &rustc_data_structures[ca9174053067dbfd]::sync::worker_local::WorkerLocal<rustc_hir[6cfa7645bd0a50ff]::Arena>, rustc_driver_impl[b59eeeb9fc736c31]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  19:     0x7f9d8787e261 - rustc_interface[923b877a2cdf5a67]::interface::run_compiler::<(), rustc_driver_impl[b59eeeb9fc736c31]::run_compiler::{closure#0}>::{closure#1}
  20:     0x7f9d878601fe - std[bd410f491febadb6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[923b877a2cdf5a67]::util::run_in_thread_with_globals<rustc_interface[923b877a2cdf5a67]::util::run_in_thread_pool_with_globals<rustc_interface[923b877a2cdf5a67]::interface::run_compiler<(), rustc_driver_impl[b59eeeb9fc736c31]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  21:     0x7f9d87860720 - <std[bd410f491febadb6]::thread::lifecycle::spawn_unchecked<rustc_interface[923b877a2cdf5a67]::util::run_in_thread_with_globals<rustc_interface[923b877a2cdf5a67]::util::run_in_thread_pool_with_globals<rustc_interface[923b877a2cdf5a67]::interface::run_compiler<(), rustc_driver_impl[b59eeeb9fc736c31]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2ca3c49344714521]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x7f9d878615ac - <std[bd410f491febadb6]::sys::thread::unix::Thread>::new::thread_start
  23:     0x7f9d8109698b - <unknown>
  24:     0x7f9d8111a9cc - <unknown>
  25:                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.95.0-nightly (13c38730d 2026-02-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 2 previous errors


Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions