Skip to content

[ICE]: ID HirId(DefId( .. )) not encountered when visiting item HIR #158812

Description

@matthiaskrgr

snippet:

#![feature(fn_delegation)]
pub trait Trait<'a> {
    fn foo(&self);
}
pub struct S<'a, A>(&'a A);
impl<'a, A> Trait<'a> for S<'a, A> {
    reuse Trait::<A = ()>::foo ;
}

fn main() {}

Version information

rustc 1.98.0-nightly (4eb62535f 2026-07-05)
binary: rustc
commit-hash: 4eb62535fc12dd1a63fd43a4173e224e79313c4d
commit-date: 2026-07-05
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

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

Program output

warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.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

warning: function cannot return without recursing
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.rs:7:28
  |
7 |     reuse Trait::<A = ()>::foo ;
  |                            ^^^
  |                            |
  |                            cannot return without recursing
  |                            recursive call site
  |
  = help: a `loop` may express intention better if this is on purpose
  = note: `#[warn(unconditional_recursion)]` on by default

warning: field `0` is never read
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.rs:5:21
  |
5 | pub struct S<'a, A>(&'a A);
  |            -        ^^^^^
  |            |
  |            field in this struct
  |
  = help: consider removing this field
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: 3 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: ID HirId(DefId(0:14 ~ mvce[5142]::{impl#0}::foo).5) not encountered when visiting item HIR
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.rs:7:5
  |
7 |     reuse Trait::<A = ()>::foo ;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at /rustc-dev/4eb62535fc12dd1a63fd43a4173e224e79313c4d/compiler/rustc_ast_lowering/src/index.rs:66:23
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_ast_lowering::LoweringContext>::make_owner_info
         5: rustc_ast_lowering::lower_to_hir
         6: rustc_query_impl::query_impl::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
         7: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 16]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
         8: rustc_query_impl::query_impl::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
         9: rustc_query_impl::query_impl::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
        10: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 32]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        11: rustc_query_impl::query_impl::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
        12: <rustc_middle::hir::map::ItemCollector as rustc_hir::intravisit::Visitor>::visit_nested_item
        13: rustc_middle::hir::map::hir_crate_items
        14: rustc_query_impl::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
        15: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
        16: rustc_query_impl::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
        17: rustc_interface::passes::analysis
        18: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
        19: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
        20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        21: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        22: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        23: <std::sys::thread::unix::Thread>::new::thread_start
        24: <unknown>
        25: <unknown>
      
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.rs:7:5
  |
7 |     reuse Trait::<A = ()>::foo ;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: ID HirId(DefId(0:14 ~ mvce[5142]::{impl#0}::foo).6) not encountered when visiting item HIR
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.rs:7:5
  |
7 |     reuse Trait::<A = ()>::foo ;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at /rustc-dev/4eb62535fc12dd1a63fd43a4173e224e79313c4d/compiler/rustc_ast_lowering/src/index.rs:66:23
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_ast_lowering::LoweringContext>::make_owner_info
         5: rustc_ast_lowering::lower_to_hir
         6: rustc_query_impl::query_impl::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
         7: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 16]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
         8: rustc_query_impl::query_impl::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
         9: rustc_query_impl::query_impl::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
        10: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 32]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        11: rustc_query_impl::query_impl::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
        12: <rustc_middle::hir::map::ItemCollector as rustc_hir::intravisit::Visitor>::visit_nested_item
        13: rustc_middle::hir::map::hir_crate_items
        14: rustc_query_impl::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
        15: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
        16: rustc_query_impl::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
        17: rustc_interface::passes::analysis
        18: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
        19: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
        20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        21: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        22: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        23: <std::sys::thread::unix::Thread>::new::thread_start
        24: <unknown>
        25: <unknown>
      
 --> /tmp/icemaker_global_tempdir.7EHXKLJUGCfC/rustc_testrunner_tmpdir_reporting.sdvic6YC0jtS/mvce.rs:7:5
  |
7 |     reuse Trait::<A = ()>::foo ;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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.98.0-nightly (4eb62535f 2026-07-05) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@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