Skip to content

ICE: delegation: unreachable #150152

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

mod to_reuse { pub fn foo() {} }
struct S< S >;
impl Item for S<S> {
    reuse to_reuse::foo;
}

original:

mod to_reuse { pub fn foo() {} }
struct S< S >;
impl Item for S<S> {
    reuse to_reuse::foo;
}
fn main() {}

Version information

rustc 1.94.0-nightly (07a5b02a2 2025-12-19)
binary: rustc
commit-hash: 07a5b02a2dfa2f1d7fc51b0133d545afc13849dd
commit-date: 2025-12-19
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

),
// For trait impl's `sig_id` is always equal to the corresponding trait method.
// For inherent methods delegation is not yet supported.
(FnKind::AssocTraitImpl, _)
| (_, FnKind::AssocTraitImpl)
| (_, FnKind::AssocInherentImpl) => unreachable!(),
}
}
pub(crate) fn inherit_predicates_for_delegation_item<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,

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

Program output

error[E0405]: cannot find trait `Item` in this scope
 --> /tmp/icemaker_global_tempdir.knj0uoUcipRR/rustc_testrunner_tmpdir_reporting.Wr4SrHda33Rx/mvce.rs:3:6
  |
3 | impl Item for S<S> {
  |      ^^^^ not found in this scope

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.knj0uoUcipRR/rustc_testrunner_tmpdir_reporting.Wr4SrHda33Rx/mvce.rs:4:5
  |
4 |     reuse to_reuse::foo;
  |     ^^^^^^^^^^^^^^^^^^^^
  |
  = 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 2025-12-19; consider upgrading it if it is out of date

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


thread 'rustc' (658477) panicked at compiler/rustc_hir_analysis/src/delegation.rs:345:45:
internal error: entered unreachable code
stack backtrace:
   0:     0x7f0ed82073b3 - <<std[4c74a2fce9bf2c5f]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9fe61ba2d6da4b2d]::fmt::Display>::fmt
   1:     0x7f0ed8810648 - core[9fe61ba2d6da4b2d]::fmt::write
   2:     0x7f0ed821db26 - <std[4c74a2fce9bf2c5f]::sys::stdio::unix::Stderr as std[4c74a2fce9bf2c5f]::io::Write>::write_fmt
   3:     0x7f0ed81ddaa8 - std[4c74a2fce9bf2c5f]::panicking::default_hook::{closure#0}
   4:     0x7f0ed81fb223 - std[4c74a2fce9bf2c5f]::panicking::default_hook
   5:     0x7f0ed71e7ed7 - std[4c74a2fce9bf2c5f]::panicking::update_hook::<alloc[74f421483eb98d63]::boxed::Box<rustc_driver_impl[a2c782fc25686226]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0ed81fb502 - std[4c74a2fce9bf2c5f]::panicking::panic_with_hook
   7:     0x7f0ed81ddb9a - std[4c74a2fce9bf2c5f]::panicking::panic_handler::{closure#0}
   8:     0x7f0ed81d2369 - std[4c74a2fce9bf2c5f]::sys::backtrace::__rust_end_short_backtrace::<std[4c74a2fce9bf2c5f]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f0ed81df71d - __rustc[b4174ff09eddacad]::rust_begin_unwind
  10:     0x7f0ed527358c - core[9fe61ba2d6da4b2d]::panicking::panic_fmt
  11:     0x7f0ed49a6c72 - core[9fe61ba2d6da4b2d]::panicking::panic
  12:     0x7f0ed9055639 - rustc_hir_analysis[23d422958f87a7df]::collect::generics_of::generics_of
  13:     0x7f0ed8818529 - rustc_query_impl[a0a98bf419192c37]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0a98bf419192c37]::query_impl::generics_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 8usize]>>
  14:     0x7f0ed8818c06 - rustc_query_system[864220176bb95b8e]::query::plumbing::try_execute_query::<rustc_query_impl[a0a98bf419192c37]::DynamicConfig<rustc_query_system[864220176bb95b8e]::query::caches::DefIdCache<rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a0a98bf419192c37]::plumbing::QueryCtxt, false>
  15:     0x7f0ed881892b - rustc_query_impl[a0a98bf419192c37]::query_impl::generics_of::get_query_non_incr::__rust_end_short_backtrace
  16:     0x7f0ed55d66f8 - rustc_hir_analysis[23d422958f87a7df]::variance::crate_variances
  17:     0x7f0ed99b5faa - rustc_query_impl[a0a98bf419192c37]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0a98bf419192c37]::query_impl::crate_variances::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 8usize]>>
  18:     0x7f0ed99b55dd - rustc_query_system[864220176bb95b8e]::query::plumbing::try_execute_query::<rustc_query_impl[a0a98bf419192c37]::DynamicConfig<rustc_query_system[864220176bb95b8e]::query::caches::SingleCache<rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a0a98bf419192c37]::plumbing::QueryCtxt, false>
  19:     0x7f0ed99b4cc0 - rustc_query_impl[a0a98bf419192c37]::query_impl::crate_variances::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7f0ed9f27ad2 - rustc_query_impl[a0a98bf419192c37]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0a98bf419192c37]::query_impl::variances_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 16usize]>>.warm
  21:     0x7f0ed88f0dd1 - <rustc_query_impl[a0a98bf419192c37]::query_impl::variances_of::dynamic_query::{closure#2} as core[9fe61ba2d6da4b2d]::ops::function::FnOnce<(rustc_middle[3d58750448771592]::ty::context::TyCtxt, rustc_span[e672eaeb0cbdeb6f]::def_id::DefId)>>::call_once
  22:     0x7f0ed88ef3a1 - rustc_query_system[864220176bb95b8e]::query::plumbing::try_execute_query::<rustc_query_impl[a0a98bf419192c37]::DynamicConfig<rustc_query_system[864220176bb95b8e]::query::caches::DefIdCache<rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[a0a98bf419192c37]::plumbing::QueryCtxt, false>
  23:     0x7f0ed88eeef2 - rustc_query_impl[a0a98bf419192c37]::query_impl::variances_of::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f0ed9058a85 - rustc_hir_analysis[23d422958f87a7df]::check::wfcheck::check_variances_for_type_defn
  25:     0x7f0ed8f2472f - rustc_hir_analysis[23d422958f87a7df]::check::check::check_item_type
  26:     0x7f0ed8f1f036 - rustc_hir_analysis[23d422958f87a7df]::check::wfcheck::check_well_formed
  27:     0x7f0ed8f1f017 - rustc_query_impl[a0a98bf419192c37]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0a98bf419192c37]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7f0ed8f1e88d - rustc_query_system[864220176bb95b8e]::query::plumbing::try_execute_query::<rustc_query_impl[a0a98bf419192c37]::DynamicConfig<rustc_data_structures[e44aecb238e9f44f]::vec_cache::VecCache<rustc_span[e672eaeb0cbdeb6f]::def_id::LocalDefId, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[864220176bb95b8e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a0a98bf419192c37]::plumbing::QueryCtxt, false>
  29:     0x7f0ed8f1e396 - rustc_query_impl[a0a98bf419192c37]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f0ed8f1bb30 - rustc_hir_analysis[23d422958f87a7df]::check::wfcheck::check_type_wf
  31:     0x7f0ed8f1ba1d - rustc_query_impl[a0a98bf419192c37]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0a98bf419192c37]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7f0ed99b2e54 - rustc_query_system[864220176bb95b8e]::query::plumbing::try_execute_query::<rustc_query_impl[a0a98bf419192c37]::DynamicConfig<rustc_query_system[864220176bb95b8e]::query::caches::SingleCache<rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a0a98bf419192c37]::plumbing::QueryCtxt, false>
  33:     0x7f0ed99b2c36 - rustc_query_impl[a0a98bf419192c37]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f0ed9304518 - rustc_hir_analysis[23d422958f87a7df]::check_crate
  35:     0x7f0ed8b93d1b - rustc_interface[d43cea5cb0259171]::passes::analysis
  36:     0x7f0ed8b93965 - rustc_query_impl[a0a98bf419192c37]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a0a98bf419192c37]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7f0ed99b4626 - rustc_query_system[864220176bb95b8e]::query::plumbing::try_execute_query::<rustc_query_impl[a0a98bf419192c37]::DynamicConfig<rustc_query_system[864220176bb95b8e]::query::caches::SingleCache<rustc_middle[3d58750448771592]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a0a98bf419192c37]::plumbing::QueryCtxt, false>
  38:     0x7f0ed99b41f6 - rustc_query_impl[a0a98bf419192c37]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f0ed9b7fed4 - <rustc_interface[d43cea5cb0259171]::passes::create_and_enter_global_ctxt<core[9fe61ba2d6da4b2d]::option::Option<rustc_interface[d43cea5cb0259171]::queries::Linker>, rustc_driver_impl[a2c782fc25686226]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[9fe61ba2d6da4b2d]::ops::function::FnOnce<(&rustc_session[cb9669c7b5ad4b36]::session::Session, rustc_middle[3d58750448771592]::ty::context::CurrentGcx, alloc[74f421483eb98d63]::sync::Arc<rustc_data_structures[e44aecb238e9f44f]::jobserver::Proxy>, &std[4c74a2fce9bf2c5f]::sync::once_lock::OnceLock<rustc_middle[3d58750448771592]::ty::context::GlobalCtxt>, &rustc_data_structures[e44aecb238e9f44f]::sync::worker_local::WorkerLocal<rustc_middle[3d58750448771592]::arena::Arena>, &rustc_data_structures[e44aecb238e9f44f]::sync::worker_local::WorkerLocal<rustc_hir[4ee98cbafbf8416b]::Arena>, rustc_driver_impl[a2c782fc25686226]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  40:     0x7f0ed98fd01a - rustc_interface[d43cea5cb0259171]::interface::run_compiler::<(), rustc_driver_impl[a2c782fc25686226]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f0ed98e7f4e - std[4c74a2fce9bf2c5f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d43cea5cb0259171]::util::run_in_thread_with_globals<rustc_interface[d43cea5cb0259171]::util::run_in_thread_pool_with_globals<rustc_interface[d43cea5cb0259171]::interface::run_compiler<(), rustc_driver_impl[a2c782fc25686226]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7f0ed98e7d20 - <std[4c74a2fce9bf2c5f]::thread::lifecycle::spawn_unchecked<rustc_interface[d43cea5cb0259171]::util::run_in_thread_with_globals<rustc_interface[d43cea5cb0259171]::util::run_in_thread_pool_with_globals<rustc_interface[d43cea5cb0259171]::interface::run_compiler<(), rustc_driver_impl[a2c782fc25686226]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9fe61ba2d6da4b2d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f0ed98e60f8 - <std[4c74a2fce9bf2c5f]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7f0ed329698b - <unknown>
  45:     0x7f0ed331a9cc - <unknown>
  46:                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.94.0-nightly (07a5b02a2 2025-12-19) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [generics_of] computing generics of `<impl at /tmp/icemaker_global_tempdir.knj0uoUcipRR/rustc_testrunner_tmpdir_reporting.Wr4SrHda33Rx/mvce.rs:3:1: 3:19>::foo`
#1 [crate_variances] computing the variances for items in this crate
#2 [variances_of] computing the variances of `S`
#3 [check_well_formed] checking that `S` is well-formed
#4 [check_type_wf] checking that types are well-formed
#5 [analysis] running analysis passes on crate `mvce`
end of query stack
error[E0107]: missing generics for struct `S`
 --> /tmp/icemaker_global_tempdir.knj0uoUcipRR/rustc_testrunner_tmpdir_reporting.Wr4SrHda33Rx/mvce.rs:3:17
  |
3 | impl Item for S<S> {
  |                 ^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `S`
 --> /tmp/icemaker_global_tempdir.knj0uoUcipRR/rustc_testrunner_tmpdir_reporting.Wr4SrHda33Rx/mvce.rs:2:8
  |
2 | struct S< S >;
  |        ^  -
help: add missing generic argument
  |
3 | impl Item for S<S<S>> {
  |                  +++

error: aborting due to 4 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions