Skip to content

[ICE]: attempted .def_id() on invalid res: Err #153389

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait{
    fn bar();
}

impl Trait for () {
    reuse missing::<> as bar;
}

original:

#![feature(fn_delegation)]
trait Trait{
    fn bar();
}

impl Trait for () {
    reuse missing::<> as bar;
}

fn main() {}

Version information

rustc 1.96.0-nightly (d933cf483 2026-03-04)
binary: rustc
commit-hash: d933cf483edf1605142ac6899ff32536c0ad8b22
commit-date: 2026-03-04
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

impl<Id> Res<Id> {
/// Return the `DefId` of this `Def` if it has an ID, else panic.
pub fn def_id(&self) -> DefId
where
Id: Debug,
{
self.opt_def_id().unwrap_or_else(|| panic!("attempted .def_id() on invalid res: {self:?}"))
}
/// Return `Some(..)` with the `DefId` of this `Res` if it has a ID, else `None`.
pub fn opt_def_id(&self) -> Option<DefId> {
match *self {
Res::Def(_, id) => Some(id),

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

Program output

error[E0425]: cannot find function `missing` in this scope
 --> /tmp/icemaker_global_tempdir.TGV4D8uIv167/rustc_testrunner_tmpdir_reporting.czTJlkk5GKxF/mvce.rs:7:11
  |
7 |     reuse missing::<> as bar;
  |           ^^^^^^^ not found in this scope

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.TGV4D8uIv167/rustc_testrunner_tmpdir_reporting.czTJlkk5GKxF/mvce.rs:7:5
  |
7 |     reuse missing::<> 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-04; consider upgrading it if it is out of date

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


thread 'rustc' (1102290) panicked at /rustc-dev/d933cf483edf1605142ac6899ff32536c0ad8b22/compiler/rustc_hir/src/def.rs:827:45:
attempted .def_id() on invalid res: Err
stack backtrace:
   0:     0x7f3fc935ef7b - <<std[69d51b4813ba037]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[51d4adbef590f61]::fmt::Display>::fmt
   1:     0x7f3fc9a229c8 - core[51d4adbef590f61]::fmt::write
   2:     0x7f3fc9375f86 - <std[69d51b4813ba037]::sys::stdio::unix::Stderr as std[69d51b4813ba037]::io::Write>::write_fmt
   3:     0x7f3fc9335058 - std[69d51b4813ba037]::panicking::default_hook::{closure#0}
   4:     0x7f3fc93523e3 - std[69d51b4813ba037]::panicking::default_hook
   5:     0x7f3fc833d71c - std[69d51b4813ba037]::panicking::update_hook::<alloc[18203fec9a0cd4ec]::boxed::Box<rustc_driver_impl[9032f3c5cdcc149c]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f3fc93526c2 - std[69d51b4813ba037]::panicking::panic_with_hook
   7:     0x7f3fc9335118 - std[69d51b4813ba037]::panicking::panic_handler::{closure#0}
   8:     0x7f3fc932be49 - std[69d51b4813ba037]::sys::backtrace::__rust_end_short_backtrace::<std[69d51b4813ba037]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f3fc9336b7d - __rustc[cb16bc19fc993bd7]::rust_begin_unwind
  10:     0x7f3fc5f1895c - core[51d4adbef590f61]::panicking::panic_fmt
  11:     0x7f3fc84d589b - rustc_hir_analysis[bceba1a8102fadd5]::delegation::get_delegation_user_specified_args
  12:     0x7f3fc84d445f - rustc_hir_analysis[bceba1a8102fadd5]::delegation::inherit_sig_for_delegation_item
  13:     0x7f3fc8deea92 - rustc_query_impl[540cdfee4f8a4756]::query_impl::inherit_sig_for_delegation_item::invoke_provider_fn::__rust_begin_short_backtrace
  14:     0x7f3fca41488c - rustc_query_impl[540cdfee4f8a4756]::execution::try_execute_query::<rustc_data_structures[889238d3fa4068cd]::vec_cache::VecCache<rustc_span[a0277d8dc90b615]::def_id::LocalDefId, rustc_middle[7e63d2df2dd45427]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[7e63d2df2dd45427]::dep_graph::graph::DepNodeIndex>, false>
  15:     0x7f3fc8deeafa - rustc_query_impl[540cdfee4f8a4756]::query_impl::inherit_sig_for_delegation_item::execute_query_non_incr::__rust_end_short_backtrace
  16:     0x7f3fca0b5b39 - <dyn rustc_hir_analysis[bceba1a8102fadd5]::hir_ty_lowering::HirTyLowerer>::lower_ty
  17:     0x7f3fca0caeaf - <dyn rustc_hir_analysis[bceba1a8102fadd5]::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
  18:     0x7f3fc9cf14bc - rustc_hir_analysis[bceba1a8102fadd5]::collect::fn_sig
  19:     0x7f3fc9cf0c26 - rustc_query_impl[540cdfee4f8a4756]::query_impl::fn_sig::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7f3fc9cf5360 - rustc_query_impl[540cdfee4f8a4756]::execution::try_execute_query::<rustc_middle[7e63d2df2dd45427]::query::caches::DefIdCache<rustc_middle[7e63d2df2dd45427]::query::erase::ErasedData<[u8; 24usize]>>, false>
  21:     0x7f3fc9cf4853 - rustc_query_impl[540cdfee4f8a4756]::query_impl::fn_sig::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7f3fca41b66b - rustc_hir_analysis[bceba1a8102fadd5]::check::compare_impl_item::check_method_is_structurally_compatible
  23:     0x7f3fca420ac7 - rustc_hir_analysis[bceba1a8102fadd5]::check::compare_impl_item::compare_impl_item
  24:     0x7f3fca420669 - rustc_query_impl[540cdfee4f8a4756]::query_impl::compare_impl_item::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f3fca0dd219 - rustc_query_impl[540cdfee4f8a4756]::execution::try_execute_query::<rustc_data_structures[889238d3fa4068cd]::vec_cache::VecCache<rustc_span[a0277d8dc90b615]::def_id::LocalDefId, rustc_middle[7e63d2df2dd45427]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[7e63d2df2dd45427]::dep_graph::graph::DepNodeIndex>, false>
  26:     0x7f3fca0dcd0e - rustc_query_impl[540cdfee4f8a4756]::query_impl::compare_impl_item::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f3fca0e01c0 - rustc_hir_analysis[bceba1a8102fadd5]::check::check::check_item_type
  28:     0x7f3fca0ddca6 - rustc_hir_analysis[bceba1a8102fadd5]::check::wfcheck::check_well_formed
  29:     0x7f3fca0ddc87 - rustc_query_impl[540cdfee4f8a4756]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  30:     0x7f3fca0dd219 - rustc_query_impl[540cdfee4f8a4756]::execution::try_execute_query::<rustc_data_structures[889238d3fa4068cd]::vec_cache::VecCache<rustc_span[a0277d8dc90b615]::def_id::LocalDefId, rustc_middle[7e63d2df2dd45427]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[7e63d2df2dd45427]::dep_graph::graph::DepNodeIndex>, false>
  31:     0x7f3fca0dcf7b - rustc_query_impl[540cdfee4f8a4756]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7f3fca0d9e7d - rustc_hir_analysis[bceba1a8102fadd5]::check::wfcheck::check_type_wf
  33:     0x7f3fca0d9d87 - rustc_query_impl[540cdfee4f8a4756]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  34:     0x7f3fcac90057 - rustc_query_impl[540cdfee4f8a4756]::execution::try_execute_query::<rustc_middle[7e63d2df2dd45427]::query::caches::SingleCache<rustc_middle[7e63d2df2dd45427]::query::erase::ErasedData<[u8; 1usize]>>, false>
  35:     0x7f3fcac8fe29 - rustc_query_impl[540cdfee4f8a4756]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  36:     0x7f3fca3cb455 - rustc_hir_analysis[bceba1a8102fadd5]::check_crate
  37:     0x7f3fc9a65619 - rustc_interface[5b554394f8ce662a]::passes::analysis
  38:     0x7f3fcac91c1c - rustc_query_impl[540cdfee4f8a4756]::execution::try_execute_query::<rustc_middle[7e63d2df2dd45427]::query::caches::SingleCache<rustc_middle[7e63d2df2dd45427]::query::erase::ErasedData<[u8; 0usize]>>, false>
  39:     0x7f3fcac9197b - rustc_query_impl[540cdfee4f8a4756]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7f3fcac329ed - rustc_interface[5b554394f8ce662a]::interface::run_compiler::<(), rustc_driver_impl[9032f3c5cdcc149c]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f3fcac5c6fe - std[69d51b4813ba037]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5b554394f8ce662a]::util::run_in_thread_with_globals<rustc_interface[5b554394f8ce662a]::util::run_in_thread_pool_with_globals<rustc_interface[5b554394f8ce662a]::interface::run_compiler<(), rustc_driver_impl[9032f3c5cdcc149c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7f3fcac5cd60 - <std[69d51b4813ba037]::thread::lifecycle::spawn_unchecked<rustc_interface[5b554394f8ce662a]::util::run_in_thread_with_globals<rustc_interface[5b554394f8ce662a]::util::run_in_thread_pool_with_globals<rustc_interface[5b554394f8ce662a]::interface::run_compiler<(), rustc_driver_impl[9032f3c5cdcc149c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[51d4adbef590f61]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f3fcac5dbec - <std[69d51b4813ba037]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7f3fc46a598b - <unknown>
  45:     0x7f3fc4729a0c - <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.96.0-nightly (d933cf483 2026-03-04) 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.TGV4D8uIv167/rustc_testrunner_tmpdir_reporting.czTJlkk5GKxF/mvce.rs:6:1: 6:18>::bar`
#2 [compare_impl_item] checking assoc item `<impl at /tmp/icemaker_global_tempdir.TGV4D8uIv167/rustc_testrunner_tmpdir_reporting.czTJlkk5GKxF/mvce.rs:6:1: 6:18>::bar` is compatible with trait definition
#3 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.TGV4D8uIv167/rustc_testrunner_tmpdir_reporting.czTJlkk5GKxF/mvce.rs:6:1: 6: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: E0425, E0601, E0658.
For more information about an error, try `rustc --explain E0425`.

@rustbot label +F-fn_delegation

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.

    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