Skip to content

[ICE]: delegation: snapshot_vec: index out of bounds with unused type param #159128

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait {
    fn method(self);
}
struct S<S>;
impl<T> Trait for S<T> {
    reuse Trait::method { S  }
}

original:

#![feature(fn_delegation)]
trait Trait {
    fn method(self);
}
struct S<S> ;  /* { x: S }*/
impl<T> Trait for S<T> {
    reuse Trait::method { S /*{ x: () } */ }
}

fn main() {}

Version information

rustc 1.99.0-nightly (ad49852b6 2026-07-11)
binary: rustc
commit-hash: ad49852b6f3dd9c1c73fe909d8843bb7e464b387
commit-date: 2026-07-11
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

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

Program output

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.LA26kz0wXT8e/rustc_testrunner_tmpdir_reporting.gxRQtbwi7M0O/mvce.rs:6:5
  |
6 |     reuse Trait::method { S  }
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-11; consider upgrading it if it is out of date

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

error[E0392]: type parameter `S` is never used
 --> /tmp/icemaker_global_tempdir.LA26kz0wXT8e/rustc_testrunner_tmpdir_reporting.gxRQtbwi7M0O/mvce.rs:4:10
  |
4 | struct S<S>;
  |          ^ unused type parameter
  |
  = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `S` to be a const parameter, use `const S: /* Type */` instead


thread 'rustc' (3116408) panicked at /rust/deps/ena-0.14.3/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 3 but the index is 4
stack backtrace:
   0:     0x7f7a53ffbc46 - <<std[de3b7ecb4a396195]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a5634a7968bc49f0]::fmt::Display>::fmt
   1:     0x7f7a54610f48 - core[a5634a7968bc49f0]::fmt::write
   2:     0x7f7a540110bc - <std[de3b7ecb4a396195]::sys::stdio::unix::Stderr as core[a5634a7968bc49f0]::io::write::Write>::write_fmt
   3:     0x7f7a53fcffca - std[de3b7ecb4a396195]::panicking::default_hook::{closure#0}
   4:     0x7f7a53fee363 - std[de3b7ecb4a396195]::panicking::default_hook
   5:     0x7f7a52fc67ab - std[de3b7ecb4a396195]::panicking::update_hook::<alloc[de1f657d51345da4]::boxed::Box<rustc_driver_impl[4ef98c1faf29e502]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f7a53fee802 - std[de3b7ecb4a396195]::panicking::panic_with_hook
   7:     0x7f7a53fd0082 - std[de3b7ecb4a396195]::panicking::panic_handler::{closure#0}
   8:     0x7f7a53fc6d49 - std[de3b7ecb4a396195]::sys::backtrace::__rust_end_short_backtrace::<std[de3b7ecb4a396195]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f7a53fd19dd - __rustc[80c2305df47a8488]::rust_begin_unwind
  10:     0x7f7a50e48cfc - core[a5634a7968bc49f0]::panicking::panic_fmt
  11:     0x7f7a50ef37c9 - core[a5634a7968bc49f0]::panicking::panic_bounds_check
  12:     0x7f7a548ea9ff - <rustc_middle[f1a16747f86fcc9d]::ty::Ty as rustc_type_ir[9d3018d6ee60f70c]::fold::TypeSuperFoldable<rustc_middle[f1a16747f86fcc9d]::ty::context::TyCtxt>>::super_fold_with::<rustc_infer[fa3649e4e34d9ae3]::infer::resolve::OpportunisticVarResolver>
  13:     0x7f7a546d03fd - <rustc_hir_typeck[d9c3eceabeafd3fa]::fn_ctxt::FnCtxt>::coerce
  14:     0x7f7a548b823f - <rustc_hir_typeck[d9c3eceabeafd3fa]::fn_ctxt::FnCtxt>::check_argument_types
  15:     0x7f7a548fcb8e - <rustc_hir_typeck[d9c3eceabeafd3fa]::fn_ctxt::FnCtxt>::check_expr_call
  16:     0x7f7a54919df8 - <rustc_hir_typeck[d9c3eceabeafd3fa]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:     0x7f7a549244a7 - <rustc_hir_typeck[d9c3eceabeafd3fa]::fn_ctxt::FnCtxt>::check_expr_block
  18:     0x7f7a54919dd2 - <rustc_hir_typeck[d9c3eceabeafd3fa]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x7f7a5494666b - rustc_hir_typeck[d9c3eceabeafd3fa]::check::check_fn
  20:     0x7f7a55888c43 - rustc_hir_typeck[d9c3eceabeafd3fa]::typeck_with_inspect::{closure#0}
  21:     0x7f7a55887530 - rustc_query_impl[f8a48d6a867b8694]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f7a55068ee9 - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_data_structures[84f0c090dd236aae]::vec_cache::VecCache<rustc_span[1cf83d6190130360]::def_id::LocalDefId, rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[f1a16747f86fcc9d]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7f7a55068943 - rustc_query_impl[f8a48d6a867b8694]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f7a5506b039 - <rustc_middle[f1a16747f86fcc9d]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[6392d7eaa5751367]::check_crate::{closure#1}>::{closure#0}
  25:     0x7f7a5506a940 - rustc_hir_analysis[6392d7eaa5751367]::check_crate
  26:     0x7f7a5506560b - rustc_interface[45196e524e7bee1]::passes::analysis
  27:     0x7f7a557ebb07 - rustc_query_impl[f8a48d6a867b8694]::execution::try_execute_query::<rustc_middle[f1a16747f86fcc9d]::query::caches::SingleCache<rustc_middle[f1a16747f86fcc9d]::query::erase::ErasedData<[u8; 0usize]>>, false>
  28:     0x7f7a557eb7e9 - rustc_query_impl[f8a48d6a867b8694]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f7a55783282 - rustc_interface[45196e524e7bee1]::interface::run_compiler::<(), rustc_driver_impl[4ef98c1faf29e502]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7f7a558744fa - std[de3b7ecb4a396195]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[45196e524e7bee1]::util::run_in_thread_with_globals<rustc_interface[45196e524e7bee1]::util::run_in_thread_pool_with_globals<rustc_interface[45196e524e7bee1]::interface::run_compiler<(), rustc_driver_impl[4ef98c1faf29e502]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7f7a558742ad - <std[de3b7ecb4a396195]::thread::lifecycle::spawn_unchecked<rustc_interface[45196e524e7bee1]::util::run_in_thread_with_globals<rustc_interface[45196e524e7bee1]::util::run_in_thread_pool_with_globals<rustc_interface[45196e524e7bee1]::interface::run_compiler<(), rustc_driver_impl[4ef98c1faf29e502]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a5634a7968bc49f0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f7a55872210 - <std[de3b7ecb4a396195]::sys::thread::unix::Thread>::new::thread_start
  33:     0x7f7a4f0981b9 - <unknown>
  34:     0x7f7a4f11d21c - <unknown>
  35:                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 (ad49852b6 2026-07-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck_root] type-checking `<impl at /tmp/icemaker_global_tempdir.LA26kz0wXT8e/rustc_testrunner_tmpdir_reporting.gxRQtbwi7M0O/mvce.rs:5:1: 5:23>::method`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors

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

@rustbot label +F-fn_delegation

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`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

Fields

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