Skip to content

ICE: delegation: index out of bounds #150673

@matthiaskrgr

Description

@matthiaskrgr

Code

#![feature(fn_delegation)]
mod first_example {
    struct S<S>;
    trait Trait {
        reuse to_reuse::foo;
    }
    mod to_reuse {
        fn foo<T>() -> T {}
    }
    impl Trait for S {
        reuse foo;
    }
}

Meta

rustc --version --verbose:

rustc 1.94.0-nightly (7ecabfaaf 2026-01-03)
binary: rustc
commit-hash: 7ecabfaaf1a58172cdd71f7661cf6589ddf7928f
commit-date: 2026-01-03
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Error output

error[E0425]: cannot find function `foo` in this scope
  --> code.rs:11:15
   |
11 |         reuse foo;
   |               ^^^ not found in this scope
   |
note: function `first_example::to_reuse::foo` exists but is inaccessible
  --> code.rs:8:9
   |
 8 |         fn foo<T>() -> T {}
   |         ^^^^^^^^^^^^^^^^ not accessible

error[E0603]: function `foo` is private
 --> code.rs:5:25
  |
5 |         reuse to_reuse::foo;
  |                         ^^^ private function
  |
note: the function `foo` is defined here
 --> code.rs:8:9
  |
8 |         fn foo<T>() -> T {}
  |         ^^^^^^^^^^^^^^^^

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

error[E0601]: `main` function not found in crate `code`
  --> code.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `code.rs`

error[E0107]: missing generics for struct `S`
  --> code.rs:10:20
   |
10 |     impl Trait for S {
   |                    ^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `S`
  --> code.rs:3:12
   |
 3 |     struct S<S>;
   |            ^ -
help: add missing generic argument
   |
10 |     impl Trait for S<S> {
   |                     +++
Backtrace

thread 'rustc' (1254997) panicked at /rustc-dev/7ecabfaaf1a58172cdd71f7661cf6589ddf7928f/compiler/rustc_hir_analysis/src/variance/solve.rs:78:47:
index out of bounds: the len is 6 but the index is 6
stack backtrace:
   0:     0x7fb776a313f3 - <<std[dfad6fe52c7ffb96]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[155fa69bcf1a74aa]::fmt::Display>::fmt
   1:     0x7fb77700e2c8 - core[155fa69bcf1a74aa]::fmt::write
   2:     0x7fb776a47b16 - <std[dfad6fe52c7ffb96]::sys::stdio::unix::Stderr as std[dfad6fe52c7ffb96]::io::Write>::write_fmt
   3:     0x7fb776a07be8 - std[dfad6fe52c7ffb96]::panicking::default_hook::{closure#0}
   4:     0x7fb776a25333 - std[dfad6fe52c7ffb96]::panicking::default_hook
   5:     0x7fb775a0d37a - std[dfad6fe52c7ffb96]::panicking::update_hook::<alloc[52b53f39752dbf3]::boxed::Box<rustc_driver_impl[27820d298b08c973]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fb776a25612 - std[dfad6fe52c7ffb96]::panicking::panic_with_hook
   7:     0x7fb776a07ca8 - std[dfad6fe52c7ffb96]::panicking::panic_handler::{closure#0}
   8:     0x7fb7769fee19 - std[dfad6fe52c7ffb96]::sys::backtrace::__rust_end_short_backtrace::<std[dfad6fe52c7ffb96]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fb776a0975d - __rustc[4205645c07b58ae0]::rust_begin_unwind
  10:     0x7fb7737427cc - core[155fa69bcf1a74aa]::panicking::panic_fmt
  11:     0x7fb773ad7943 - core[155fa69bcf1a74aa]::panicking::panic_bounds_check
  12:     0x7fb773a6b9d6 - rustc_hir_analysis[87ca905f401f0fa5]::variance::crate_variances
  13:     0x7fb77819c670 - rustc_query_impl[6ad7e1bd79b807cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6ad7e1bd79b807cf]::query_impl::crate_variances::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 8usize]>>
  14:     0x7fb77819bbd9 - rustc_query_system[27e38e26a46ba8cb]::query::plumbing::try_execute_query::<rustc_query_impl[6ad7e1bd79b807cf]::DynamicConfig<rustc_query_system[27e38e26a46ba8cb]::query::caches::SingleCache<rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[6ad7e1bd79b807cf]::plumbing::QueryCtxt, false>
  15:     0x7fb77819b200 - rustc_query_impl[6ad7e1bd79b807cf]::query_impl::crate_variances::get_query_non_incr::__rust_end_short_backtrace
  16:     0x7fb777169297 - rustc_query_impl[6ad7e1bd79b807cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6ad7e1bd79b807cf]::query_impl::variances_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 16usize]>>
  17:     0x7fb777168e11 - <rustc_query_impl[6ad7e1bd79b807cf]::query_impl::variances_of::dynamic_query::{closure#2} as core[155fa69bcf1a74aa]::ops::function::FnOnce<(rustc_middle[4a73b4962f75d7b5]::ty::context::TyCtxt, rustc_span[3c3ff8aa0c1565a]::def_id::DefId)>>::call_once
  18:     0x7fb7771673e1 - rustc_query_system[27e38e26a46ba8cb]::query::plumbing::try_execute_query::<rustc_query_impl[6ad7e1bd79b807cf]::DynamicConfig<rustc_query_system[27e38e26a46ba8cb]::query::caches::DefIdCache<rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[6ad7e1bd79b807cf]::plumbing::QueryCtxt, false>
  19:     0x7fb777166f32 - rustc_query_impl[6ad7e1bd79b807cf]::query_impl::variances_of::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7fb7777c8435 - rustc_hir_analysis[87ca905f401f0fa5]::check::wfcheck::check_variances_for_type_defn
  21:     0x7fb777667519 - rustc_hir_analysis[87ca905f401f0fa5]::check::check::check_item_type
  22:     0x7fb777661e36 - rustc_hir_analysis[87ca905f401f0fa5]::check::wfcheck::check_well_formed
  23:     0x7fb777661e17 - rustc_query_impl[6ad7e1bd79b807cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6ad7e1bd79b807cf]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 1usize]>>
  24:     0x7fb77766168d - rustc_query_system[27e38e26a46ba8cb]::query::plumbing::try_execute_query::<rustc_query_impl[6ad7e1bd79b807cf]::DynamicConfig<rustc_data_structures[d5655ec51fef7d7c]::vec_cache::VecCache<rustc_span[3c3ff8aa0c1565a]::def_id::LocalDefId, rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[27e38e26a46ba8cb]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[6ad7e1bd79b807cf]::plumbing::QueryCtxt, false>
  25:     0x7fb777661196 - rustc_query_impl[6ad7e1bd79b807cf]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7fb77765e930 - rustc_hir_analysis[87ca905f401f0fa5]::check::wfcheck::check_type_wf
  27:     0x7fb77765e81d - rustc_query_impl[6ad7e1bd79b807cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6ad7e1bd79b807cf]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7fb778199388 - rustc_query_system[27e38e26a46ba8cb]::query::plumbing::try_execute_query::<rustc_query_impl[6ad7e1bd79b807cf]::DynamicConfig<rustc_query_system[27e38e26a46ba8cb]::query::caches::SingleCache<rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6ad7e1bd79b807cf]::plumbing::QueryCtxt, false>
  29:     0x7fb77819914e - rustc_query_impl[6ad7e1bd79b807cf]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7fb777a52634 - rustc_hir_analysis[87ca905f401f0fa5]::check_crate
  31:     0x7fb777ea489b - rustc_interface[efcfa671571f034]::passes::analysis
  32:     0x7fb777ea44f5 - rustc_query_impl[6ad7e1bd79b807cf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6ad7e1bd79b807cf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7fb77819ab66 - rustc_query_system[27e38e26a46ba8cb]::query::plumbing::try_execute_query::<rustc_query_impl[6ad7e1bd79b807cf]::DynamicConfig<rustc_query_system[27e38e26a46ba8cb]::query::caches::SingleCache<rustc_middle[4a73b4962f75d7b5]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6ad7e1bd79b807cf]::plumbing::QueryCtxt, false>
  34:     0x7fb77819a736 - rustc_query_impl[6ad7e1bd79b807cf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7fb778364711 - <rustc_interface[efcfa671571f034]::passes::create_and_enter_global_ctxt<core[155fa69bcf1a74aa]::option::Option<rustc_interface[efcfa671571f034]::queries::Linker>, rustc_driver_impl[27820d298b08c973]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[155fa69bcf1a74aa]::ops::function::FnOnce<(&rustc_session[7cf5aa466d461367]::session::Session, rustc_middle[4a73b4962f75d7b5]::ty::context::CurrentGcx, alloc[52b53f39752dbf3]::sync::Arc<rustc_data_structures[d5655ec51fef7d7c]::jobserver::Proxy>, &std[dfad6fe52c7ffb96]::sync::once_lock::OnceLock<rustc_middle[4a73b4962f75d7b5]::ty::context::GlobalCtxt>, &rustc_data_structures[d5655ec51fef7d7c]::sync::worker_local::WorkerLocal<rustc_middle[4a73b4962f75d7b5]::arena::Arena>, &rustc_data_structures[d5655ec51fef7d7c]::sync::worker_local::WorkerLocal<rustc_hir[a4563a91cd9984ff]::Arena>, rustc_driver_impl[27820d298b08c973]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  36:     0x7fb7781f36d8 - rustc_interface[efcfa671571f034]::interface::run_compiler::<(), rustc_driver_impl[27820d298b08c973]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7fb77816368e - std[dfad6fe52c7ffb96]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[efcfa671571f034]::util::run_in_thread_with_globals<rustc_interface[efcfa671571f034]::util::run_in_thread_pool_with_globals<rustc_interface[efcfa671571f034]::interface::run_compiler<(), rustc_driver_impl[27820d298b08c973]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x7fb778163460 - <std[dfad6fe52c7ffb96]::thread::lifecycle::spawn_unchecked<rustc_interface[efcfa671571f034]::util::run_in_thread_with_globals<rustc_interface[efcfa671571f034]::util::run_in_thread_pool_with_globals<rustc_interface[efcfa671571f034]::interface::run_compiler<(), rustc_driver_impl[27820d298b08c973]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[155fa69bcf1a74aa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7fb778168db8 - <std[dfad6fe52c7ffb96]::sys::thread::unix::Thread>::new::thread_start
  40:     0x7fb771a9698b - <unknown>
  41:     0x7fb771b1a9cc - <unknown>
  42:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-01-04T14_10_17-1254883.txt` to your bug report

note: rustc 1.94.0-nightly (7ecabfaaf 2026-01-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [crate_variances] computing the variances for items in this crate
#1 [variances_of] computing the variances of `first_example::S`
#2 [check_well_formed] checking that `first_example::S` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

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

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) ❄️S-has-bisectionStatus: A bisection has been found for this issueT-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