Skip to content

[ICE]: diagnostics: index out of bounds let target_param = &struct_generics.params[idx] #154165

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct A;
impl A<B> {}

original:

struct A;
impl A<B> {}
fn main() {}

Version information

rustc 1.96.0-nightly (44e662074 2026-03-21)
binary: rustc
commit-hash: 44e662074f187af2723a26182f06ffff17d833e6
commit-date: 2026-03-21
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

source,
) && let Some(resolve) = resolve.full_res()
&& let Res::Def(_, def_id) = resolve
&& def_id.is_local()
&& let Some(local_def_id) = def_id.as_local()
&& let Some(struct_generics) = self.r.struct_generics.get(&local_def_id)
&& let target_param = &struct_generics.params[idx]
&& let GenericParamKind::Const { ty, .. } = &target_param.kind
&& let TyKind::Path(_, path) = &ty.kind
{
let full_type = path
.segments
.iter()

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

Program output


thread 'rustc' (1695678) panicked at /rustc-dev/44e662074f187af2723a26182f06ffff17d833e6/compiler/rustc_resolve/src/late/diagnostics.rs:3384:36:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f735a7a4efb - <<std[67bae6351216b547]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b30d1e4e5a844562]::fmt::Display>::fmt
   1:     0x7f735ae2e148 - core[b30d1e4e5a844562]::fmt::write
   2:     0x7f735a7bbf06 - <std[67bae6351216b547]::sys::stdio::unix::Stderr as std[67bae6351216b547]::io::Write>::write_fmt
   3:     0x7f735a77af08 - std[67bae6351216b547]::panicking::default_hook::{closure#0}
   4:     0x7f735a798303 - std[67bae6351216b547]::panicking::default_hook
   5:     0x7f735979117c - std[67bae6351216b547]::panicking::update_hook::<alloc[6c4275e16e664f15]::boxed::Box<rustc_driver_impl[f15c86420af2366]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f735a7985e2 - std[67bae6351216b547]::panicking::panic_with_hook
   7:     0x7f735a77afc8 - std[67bae6351216b547]::panicking::panic_handler::{closure#0}
   8:     0x7f735a771cf9 - std[67bae6351216b547]::sys::backtrace::__rust_end_short_backtrace::<std[67bae6351216b547]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f735a77ca2d - __rustc[cf5e8c4616c45f27]::rust_begin_unwind
  10:     0x7f73578076ac - core[b30d1e4e5a844562]::panicking::panic_fmt
  11:     0x7f7357780e72 - core[b30d1e4e5a844562]::panicking::panic_bounds_check
  12:     0x7f735a31994f - <rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor>::detect_and_suggest_const_parameter_error
  13:     0x7f73571fbc97 - <rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor>::smart_resolve_path_fragment::{closure#0}
  14:     0x7f735bb541fb - <rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor>::smart_resolve_path_fragment
  15:     0x7f735bb521a9 - <rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor as rustc_ast[f3e7ecc0246e0ee7]::visit::Visitor>::visit_ty
  16:     0x7f735bb524f2 - <rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor as rustc_ast[f3e7ecc0246e0ee7]::visit::Visitor>::visit_ty
  17:     0x7f735bb6a3b4 - <rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor>::resolve_item
  18:     0x7f735bb690c3 - rustc_ast[f3e7ecc0246e0ee7]::visit::visit_items::<rustc_resolve[71896364d49c6596]::late::LateResolutionVisitor>
  19:     0x7f735b3c0be4 - <rustc_resolve[71896364d49c6596]::Resolver>::resolve_crate::{closure#0}
  20:     0x7f735b3be6c7 - <rustc_resolve[71896364d49c6596]::Resolver>::resolve_crate
  21:     0x7f735b3a59c9 - rustc_interface[adb13c4b1c58cd5]::passes::configure_and_expand
  22:     0x7f735c048678 - rustc_interface[adb13c4b1c58cd5]::passes::resolver_for_lowering_raw
  23:     0x7f735c0483f3 - rustc_query_impl[971313cfa79974c6]::query_impl::resolver_for_lowering_raw::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7f735c026229 - rustc_query_impl[971313cfa79974c6]::execution::try_execute_query::<rustc_middle[69765d1c068851e5]::query::caches::SingleCache<rustc_middle[69765d1c068851e5]::query::erase::ErasedData<[u8; 16usize]>>, false>
  25:     0x7f735c025d8e - rustc_query_impl[971313cfa79974c6]::query_impl::resolver_for_lowering_raw::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7f735bffc0be - rustc_interface[adb13c4b1c58cd5]::interface::run_compiler::<(), rustc_driver_impl[f15c86420af2366]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7f735bfe55fe - std[67bae6351216b547]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[adb13c4b1c58cd5]::util::run_in_thread_with_globals<rustc_interface[adb13c4b1c58cd5]::util::run_in_thread_pool_with_globals<rustc_interface[adb13c4b1c58cd5]::interface::run_compiler<(), rustc_driver_impl[f15c86420af2366]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  28:     0x7f735bfe5ea0 - <std[67bae6351216b547]::thread::lifecycle::spawn_unchecked<rustc_interface[adb13c4b1c58cd5]::util::run_in_thread_with_globals<rustc_interface[adb13c4b1c58cd5]::util::run_in_thread_pool_with_globals<rustc_interface[adb13c4b1c58cd5]::interface::run_compiler<(), rustc_driver_impl[f15c86420af2366]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b30d1e4e5a844562]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7f735bfe6d2c - <std[67bae6351216b547]::sys::thread::unix::Thread>::new::thread_start
  30:     0x7f7355aa597a - <unknown>
  31:     0x7f7355b292bc - <unknown>
  32:                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 (44e662074 2026-03-21) 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions