Skip to content

[ICE]: delegation: DefId doesn't have a parent #153744

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait{fn bar();}
impl Trait for () { reuse core::<>as bar; }

fn main() {}

original:

#![feature(fn_delegation)]
trait Trait{fn bar();}
impl Trait for () { reuse core::<>as bar; }

fn main() {}

Version information

rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11)
binary: rustc
commit-hash: 3b1b0ef4d80d3117924d91352c8b6ca528708b3c
commit-date: 2026-03-11
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

});
let child_args = info.child_args_segment_id.and_then(get_segment).map(|(segment, def_id)| {
let parent_args = if let Some(parent_args) = parent_args {
parent_args
} else {
let parent = tcx.parent(def_id);
if matches!(tcx.def_kind(parent), DefKind::Trait) {
ty::GenericArgs::identity_for_item(tcx, parent).as_slice()
} else {
&[]
}
};

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

Program output

error[E0423]: expected function, found crate `core`
 --> /tmp/icemaker_global_tempdir.RJgnvdOUQpUO/rustc_testrunner_tmpdir_reporting.ClRPgnMXM5Fn/mvce.rs:3:27
  |
3 | impl Trait for () { reuse core::<>as bar; }
  |                           ^^^^^^^^ not a function

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.RJgnvdOUQpUO/rustc_testrunner_tmpdir_reporting.ClRPgnMXM5Fn/mvce.rs:3:21
  |
3 | impl Trait for () { reuse core::<>as bar; }
  |                     ^^^^^^^^^^^^^^^^^^^^^
  |
  = 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-03-11; consider upgrading it if it is out of date

error: internal compiler error: /rustc-dev/3b1b0ef4d80d3117924d91352c8b6ca528708b3c/compiler/rustc_hir_analysis/src/delegation.rs:604:30: DefId(2:0 ~ core[d6e6]) doesn't have a parent


thread 'rustc' (923323) panicked at /rustc-dev/3b1b0ef4d80d3117924d91352c8b6ca528708b3c/compiler/rustc_hir_analysis/src/delegation.rs:604:30:
Box<dyn Any>
stack backtrace:
   0:     0x7fa5701488db - <<std[98a29328132e9808]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[d6e61f80bd84b1aa]::fmt::Display>::fmt
   1:     0x7fa57081cd08 - core[d6e61f80bd84b1aa]::fmt::write
   2:     0x7fa57015f8e6 - <std[98a29328132e9808]::sys::stdio::unix::Stderr as std[98a29328132e9808]::io::Write>::write_fmt
   3:     0x7fa57011e9c8 - std[98a29328132e9808]::panicking::default_hook::{closure#0}
   4:     0x7fa57013bd53 - std[98a29328132e9808]::panicking::default_hook
   5:     0x7fa56f136a0c - std[98a29328132e9808]::panicking::update_hook::<alloc[181a33ef8c443c3d]::boxed::Box<rustc_driver_impl[da6c6aa1c22ed2c8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fa57013c032 - std[98a29328132e9808]::panicking::panic_with_hook
   7:     0x7fa56f166b31 - std[98a29328132e9808]::panicking::begin_panic::<rustc_errors[97e0e08b3e2a9a96]::ExplicitBug>::{closure#0}
   8:     0x7fa56f15f816 - std[98a29328132e9808]::sys::backtrace::__rust_end_short_backtrace::<std[98a29328132e9808]::panicking::begin_panic<rustc_errors[97e0e08b3e2a9a96]::ExplicitBug>::{closure#0}, !>
   9:     0x7fa56f15d448 - std[98a29328132e9808]::panicking::begin_panic::<rustc_errors[97e0e08b3e2a9a96]::ExplicitBug>
  10:     0x7fa56f1721a1 - <rustc_errors[97e0e08b3e2a9a96]::diagnostic::BugAbort as rustc_errors[97e0e08b3e2a9a96]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fa56f74f519 - rustc_middle[c5a7798a8191db22]::util::bug::opt_span_bug_fmt::<rustc_span[2b7bdaa576714e8d]::span_encoding::Span>::{closure#0}
  12:     0x7fa56f74f6a2 - rustc_middle[c5a7798a8191db22]::ty::context::tls::with_opt::<rustc_middle[c5a7798a8191db22]::util::bug::opt_span_bug_fmt<rustc_span[2b7bdaa576714e8d]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fa56f73fe7b - rustc_middle[c5a7798a8191db22]::ty::context::tls::with_context_opt::<rustc_middle[c5a7798a8191db22]::ty::context::tls::with_opt<rustc_middle[c5a7798a8191db22]::util::bug::opt_span_bug_fmt<rustc_span[2b7bdaa576714e8d]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fa56d0ed7c4 - rustc_middle[c5a7798a8191db22]::util::bug::bug_fmt
  15:     0x7fa56f2d3b43 - rustc_hir_analysis[fb7797e3d1a18a57]::delegation::get_delegation_user_specified_args
  16:     0x7fa56f2d261f - rustc_hir_analysis[fb7797e3d1a18a57]::delegation::inherit_sig_for_delegation_item
  17:     0x7fa56fbfbc82 - rustc_query_impl[62dde3202d61a64e]::query_impl::inherit_sig_for_delegation_item::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7fa57107e71e - rustc_query_impl[62dde3202d61a64e]::execution::try_execute_query::<rustc_data_structures[3406ed04c82e19df]::vec_cache::VecCache<rustc_span[2b7bdaa576714e8d]::def_id::LocalDefId, rustc_middle[c5a7798a8191db22]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[c5a7798a8191db22]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7fa56fbfbcea - rustc_query_impl[62dde3202d61a64e]::query_impl::inherit_sig_for_delegation_item::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7fa570dd197b - <dyn rustc_hir_analysis[fb7797e3d1a18a57]::hir_ty_lowering::HirTyLowerer>::lower_ty
  21:     0x7fa570db4af2 - <dyn rustc_hir_analysis[fb7797e3d1a18a57]::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
  22:     0x7fa570a54cfc - rustc_hir_analysis[fb7797e3d1a18a57]::collect::fn_sig
  23:     0x7fa570a54466 - rustc_query_impl[62dde3202d61a64e]::query_impl::fn_sig::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7fa570a58a8e - rustc_query_impl[62dde3202d61a64e]::execution::try_execute_query::<rustc_middle[c5a7798a8191db22]::query::caches::DefIdCache<rustc_middle[c5a7798a8191db22]::query::erase::ErasedData<[u8; 24usize]>>, false>
  25:     0x7fa570a58093 - rustc_query_impl[62dde3202d61a64e]::query_impl::fn_sig::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7fa5710854eb - rustc_hir_analysis[fb7797e3d1a18a57]::check::compare_impl_item::check_method_is_structurally_compatible
  27:     0x7fa57108a923 - rustc_hir_analysis[fb7797e3d1a18a57]::check::compare_impl_item::compare_impl_item
  28:     0x7fa57108a4d9 - rustc_query_impl[62dde3202d61a64e]::query_impl::compare_impl_item::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7fa570d9567f - rustc_query_impl[62dde3202d61a64e]::execution::try_execute_query::<rustc_data_structures[3406ed04c82e19df]::vec_cache::VecCache<rustc_span[2b7bdaa576714e8d]::def_id::LocalDefId, rustc_middle[c5a7798a8191db22]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[c5a7798a8191db22]::dep_graph::graph::DepNodeIndex>, false>
  30:     0x7fa570d951b6 - rustc_query_impl[62dde3202d61a64e]::query_impl::compare_impl_item::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7fa570d985f2 - rustc_hir_analysis[fb7797e3d1a18a57]::check::check::check_item_type
  32:     0x7fa570d9609c - rustc_hir_analysis[fb7797e3d1a18a57]::check::wfcheck::check_well_formed
  33:     0x7fa570d9606d - rustc_query_impl[62dde3202d61a64e]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  34:     0x7fa570d9567f - rustc_query_impl[62dde3202d61a64e]::execution::try_execute_query::<rustc_data_structures[3406ed04c82e19df]::vec_cache::VecCache<rustc_span[2b7bdaa576714e8d]::def_id::LocalDefId, rustc_middle[c5a7798a8191db22]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[c5a7798a8191db22]::dep_graph::graph::DepNodeIndex>, false>
  35:     0x7fa570d95407 - rustc_query_impl[62dde3202d61a64e]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  36:     0x7fa570d92333 - rustc_hir_analysis[fb7797e3d1a18a57]::check::wfcheck::check_type_wf
  37:     0x7fa570d9222f - rustc_query_impl[62dde3202d61a64e]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  38:     0x7fa571aa309c - rustc_query_impl[62dde3202d61a64e]::execution::try_execute_query::<rustc_middle[c5a7798a8191db22]::query::caches::SingleCache<rustc_middle[c5a7798a8191db22]::query::erase::ErasedData<[u8; 1usize]>>, false>
  39:     0x7fa571aa2e77 - rustc_query_impl[62dde3202d61a64e]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7fa57123c2d5 - rustc_hir_analysis[fb7797e3d1a18a57]::check_crate
  41:     0x7fa5709400d3 - rustc_interface[165454881ff1a59b]::passes::analysis
  42:     0x7fa571aa2409 - rustc_query_impl[62dde3202d61a64e]::execution::try_execute_query::<rustc_middle[c5a7798a8191db22]::query::caches::SingleCache<rustc_middle[c5a7798a8191db22]::query::erase::ErasedData<[u8; 0usize]>>, false>
  43:     0x7fa571aa20e9 - rustc_query_impl[62dde3202d61a64e]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  44:     0x7fa571a56248 - rustc_interface[165454881ff1a59b]::interface::run_compiler::<(), rustc_driver_impl[da6c6aa1c22ed2c8]::run_compiler::{closure#0}>::{closure#1}
  45:     0x7fa571a7b1fe - std[98a29328132e9808]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[165454881ff1a59b]::util::run_in_thread_with_globals<rustc_interface[165454881ff1a59b]::util::run_in_thread_pool_with_globals<rustc_interface[165454881ff1a59b]::interface::run_compiler<(), rustc_driver_impl[da6c6aa1c22ed2c8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  46:     0x7fa571a7baa0 - <std[98a29328132e9808]::thread::lifecycle::spawn_unchecked<rustc_interface[165454881ff1a59b]::util::run_in_thread_with_globals<rustc_interface[165454881ff1a59b]::util::run_in_thread_pool_with_globals<rustc_interface[165454881ff1a59b]::interface::run_compiler<(), rustc_driver_impl[da6c6aa1c22ed2c8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d6e61f80bd84b1aa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:     0x7fa571a7c92c - <std[98a29328132e9808]::sys::thread::unix::Thread>::new::thread_start
  48:     0x7fa56b4a598b - <unknown>
  49:     0x7fa56b529a0c - <unknown>
  50:                0x0 - <unknown>

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 (3b1b0ef4d 2026-03-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [inherit_sig_for_delegation_item] inheriting delegation signature
#1 [fn_sig] computing function signature of `<impl at /tmp/icemaker_global_tempdir.RJgnvdOUQpUO/rustc_testrunner_tmpdir_reporting.ClRPgnMXM5Fn/mvce.rs:3:1: 3:18>::bar`
#2 [compare_impl_item] checking assoc item `<impl at /tmp/icemaker_global_tempdir.RJgnvdOUQpUO/rustc_testrunner_tmpdir_reporting.ClRPgnMXM5Fn/mvce.rs:3:1: 3:18>::bar` is compatible with trait definition
#3 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.RJgnvdOUQpUO/rustc_testrunner_tmpdir_reporting.ClRPgnMXM5Fn/mvce.rs:3:1: 3:18>` 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: aborting due to 3 previous errors

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

@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
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