Skip to content

[ICE]: delegation: No HirId for DefId #154820

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

reuse foo:: < {
    fn foo() {}
    reuse foo;
  }
  >;

original:

#![feature(fn_delegation)]

reuse foo:: < {
    fn foo() {}
    reuse foo;
  }
  >;

Version information

rustc 1.96.0-nightly (981cf6947 2026-04-04)
binary: rustc
commit-hash: 981cf69479ded5e2de0cf9e16111c19d65be0369
commit-date: 2026-04-04
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

providers.hir_crate_items = map::hir_crate_items;
providers.crate_hash = map::crate_hash;
providers.hir_module_items = map::hir_module_items;
providers.local_def_id_to_hir_id = |tcx, def_id| match tcx.hir_crate(()).owner(tcx, def_id) {
MaybeOwner::Owner(_) => HirId::make_owner(def_id),
MaybeOwner::NonOwner(hir_id) => hir_id,
MaybeOwner::Phantom => bug!("No HirId for {:?}", def_id),
};
providers.opt_hir_owner_nodes =
|tcx, id| tcx.hir_crate(()).owner(tcx, id).as_owner().map(|i| &i.nodes);
providers.hir_owner_parent_q = |tcx, owner_id| tcx.hir_owner_parent_impl(owner_id);
providers.hir_attr_map = |tcx, id| {
tcx.hir_crate(()).owner(tcx, id.def_id).as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs)

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

Program output

error[E0428]: the name `foo` is defined multiple times
 --> /tmp/icemaker_global_tempdir.B6BTH9LlK7Uj/rustc_testrunner_tmpdir_reporting.VMLpdNPqpxHZ/mvce.rs:3:5
  |
2 |     fn foo() {}
  |     -------- previous definition of the value `foo` here
3 |     reuse foo;
  |     ^^^^^^^^^^ `foo` redefined here
  |
  = note: `foo` must be defined only once in the value namespace of this block

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

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.B6BTH9LlK7Uj/rustc_testrunner_tmpdir_reporting.VMLpdNPqpxHZ/mvce.rs:1:1
  |
1 | / reuse foo:: < {
2 | |     fn foo() {}
3 | |     reuse foo;
4 | |   }
5 | |   >;
  | |____^
  |
  = 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-04-04; consider upgrading it if it is out of date

error: failed to resolve delegation callee
 --> /tmp/icemaker_global_tempdir.B6BTH9LlK7Uj/rustc_testrunner_tmpdir_reporting.VMLpdNPqpxHZ/mvce.rs:1:7
  |
1 | reuse foo:: < {
  |       ^^^

error: internal compiler error: /rustc-dev/981cf69479ded5e2de0cf9e16111c19d65be0369/compiler/rustc_middle/src/hir/mod.rs:478:32: No HirId for DefId(0:4 ~ mvce[ce0a]::foo::{constant#0})


thread 'rustc' (3346370) panicked at /rustc-dev/981cf69479ded5e2de0cf9e16111c19d65be0369/compiler/rustc_middle/src/hir/mod.rs:478:32:
Box<dyn Any>
stack backtrace:
   0:     0x7fd7519affbb - <<std[ebbe8e490f6d8018]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e0039014fbc551a9]::fmt::Display>::fmt
   1:     0x7fd75201e1c8 - core[e0039014fbc551a9]::fmt::write
   2:     0x7fd7519c6fc6 - <std[ebbe8e490f6d8018]::sys::stdio::unix::Stderr as std[ebbe8e490f6d8018]::io::Write>::write_fmt
   3:     0x7fd751985fc8 - std[ebbe8e490f6d8018]::panicking::default_hook::{closure#0}
   4:     0x7fd7519a33c3 - std[ebbe8e490f6d8018]::panicking::default_hook
   5:     0x7fd7509ada9c - std[ebbe8e490f6d8018]::panicking::update_hook::<alloc[cb39f600d6f52ef4]::boxed::Box<rustc_driver_impl[c03a371dcba30999]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd7519a36a2 - std[ebbe8e490f6d8018]::panicking::panic_with_hook
   7:     0x7fd7509dd3a1 - std[ebbe8e490f6d8018]::panicking::begin_panic::<rustc_errors[24e2b13995366241]::ExplicitBug>::{closure#0}
   8:     0x7fd7509d6086 - std[ebbe8e490f6d8018]::sys::backtrace::__rust_end_short_backtrace::<std[ebbe8e490f6d8018]::panicking::begin_panic<rustc_errors[24e2b13995366241]::ExplicitBug>::{closure#0}, !>
   9:     0x7fd7509d5deb - std[ebbe8e490f6d8018]::panicking::begin_panic::<rustc_errors[24e2b13995366241]::ExplicitBug>
  10:     0x7fd7509e89e1 - <rustc_errors[24e2b13995366241]::diagnostic::BugAbort as rustc_errors[24e2b13995366241]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fd750fbfb49 - rustc_middle[a5faf31693dbe3fb]::util::bug::opt_span_bug_fmt::<rustc_span[e72d8c7181f2d66e]::span_encoding::Span>::{closure#0}
  12:     0x7fd750fbfcd2 - rustc_middle[a5faf31693dbe3fb]::ty::context::tls::with_opt::<rustc_middle[a5faf31693dbe3fb]::util::bug::opt_span_bug_fmt<rustc_span[e72d8c7181f2d66e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fd750fb028b - rustc_middle[a5faf31693dbe3fb]::ty::context::tls::with_context_opt::<rustc_middle[a5faf31693dbe3fb]::ty::context::tls::with_opt<rustc_middle[a5faf31693dbe3fb]::util::bug::opt_span_bug_fmt<rustc_span[e72d8c7181f2d66e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fd74e10a2f4 - rustc_middle[a5faf31693dbe3fb]::util::bug::bug_fmt
  15:     0x7fd7520bc313 - rustc_query_impl[77c21dd70d39b376]::query_impl::local_def_id_to_hir_id::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7fd7520bb626 - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_data_structures[557cea3a9825f03a]::vec_cache::VecCache<rustc_span[e72d8c7181f2d66e]::def_id::LocalDefId, rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[a5faf31693dbe3fb]::dep_graph::graph::DepNodeIndex>, false>
  17:     0x7fd7520bb385 - rustc_query_impl[77c21dd70d39b376]::query_impl::local_def_id_to_hir_id::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7fd7521cc74c - <rustc_span[e72d8c7181f2d66e]::def_id::LocalDefId as rustc_hir[cbdb9c4d50c2ed1d]::attrs::HasAttrs<rustc_middle[a5faf31693dbe3fb]::ty::context::TyCtxt>>::get_attrs
  19:     0x7fd7521cbcbb - rustc_query_impl[77c21dd70d39b376]::query_impl::sanitizer_settings_for::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7fd7521cb0fb - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_data_structures[557cea3a9825f03a]::vec_cache::VecCache<rustc_span[e72d8c7181f2d66e]::def_id::LocalDefId, rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 4usize]>, rustc_middle[a5faf31693dbe3fb]::dep_graph::graph::DepNodeIndex>, false>
  21:     0x7fd7521cae7b - rustc_query_impl[77c21dd70d39b376]::query_impl::sanitizer_settings_for::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7fd7521cbd2f - rustc_query_impl[77c21dd70d39b376]::query_impl::sanitizer_settings_for::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7fd7521cb0fb - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_data_structures[557cea3a9825f03a]::vec_cache::VecCache<rustc_span[e72d8c7181f2d66e]::def_id::LocalDefId, rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 4usize]>, rustc_middle[a5faf31693dbe3fb]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7fd7521cae7b - rustc_query_impl[77c21dd70d39b376]::query_impl::sanitizer_settings_for::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7fd752580a28 - rustc_codegen_ssa[734e7c4a27baa15c]::codegen_attrs::codegen_fn_attrs
  26:     0x7fd75257f162 - rustc_query_impl[77c21dd70d39b376]::query_impl::codegen_fn_attrs::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7fd75205ef0a - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_middle[a5faf31693dbe3fb]::query::caches::DefIdCache<rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 8usize]>>, false>
  28:     0x7fd75205e790 - rustc_query_impl[77c21dd70d39b376]::query_impl::codegen_fn_attrs::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7fd75044f915 - <rustc_ast_lowering[51b7b24872d13be5]::LoweringContext<rustc_ast_lowering[51b7b24872d13be5]::ResolverDelayedAstLowering>>::lower_delegation
  30:     0x7fd7504691b2 - <rustc_ast_lowering[51b7b24872d13be5]::LoweringContext<rustc_ast_lowering[51b7b24872d13be5]::ResolverDelayedAstLowering>>::lower_item_kind
  31:     0x7fd750496647 - <rustc_ast_lowering[51b7b24872d13be5]::item::ItemLowerer<rustc_ast_lowering[51b7b24872d13be5]::ResolverDelayedAstLowering>>::lower_node
  32:     0x7fd75044b429 - rustc_ast_lowering[51b7b24872d13be5]::lower_delayed_owner
  33:     0x7fd7520ba522 - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_data_structures[557cea3a9825f03a]::vec_cache::VecCache<rustc_span[e72d8c7181f2d66e]::def_id::LocalDefId, rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 0usize]>, rustc_middle[a5faf31693dbe3fb]::dep_graph::graph::DepNodeIndex>, false>
  34:     0x7fd75144f1db - rustc_query_impl[77c21dd70d39b376]::query_impl::lower_delayed_owner::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7fd75338d1a5 - rustc_middle[a5faf31693dbe3fb]::hir::map::hir_crate_items
  36:     0x7fd753239425 - rustc_query_impl[77c21dd70d39b376]::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
  37:     0x7fd753235725 - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_middle[a5faf31693dbe3fb]::query::caches::SingleCache<rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 8usize]>>, false>
  38:     0x7fd75323458f - rustc_query_impl[77c21dd70d39b376]::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
  39:     0x7fd7520b7c18 - rustc_interface[29be6a7f2a5c93ab]::passes::analysis
  40:     0x7fd753236409 - rustc_query_impl[77c21dd70d39b376]::execution::try_execute_query::<rustc_middle[a5faf31693dbe3fb]::query::caches::SingleCache<rustc_middle[a5faf31693dbe3fb]::query::erase::ErasedData<[u8; 0usize]>>, false>
  41:     0x7fd753236075 - rustc_query_impl[77c21dd70d39b376]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7fd7531e5a9e - rustc_interface[29be6a7f2a5c93ab]::interface::run_compiler::<(), rustc_driver_impl[c03a371dcba30999]::run_compiler::{closure#0}>::{closure#1}
  43:     0x7fd7532154fe - std[ebbe8e490f6d8018]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[29be6a7f2a5c93ab]::util::run_in_thread_with_globals<rustc_interface[29be6a7f2a5c93ab]::util::run_in_thread_pool_with_globals<rustc_interface[29be6a7f2a5c93ab]::interface::run_compiler<(), rustc_driver_impl[c03a371dcba30999]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  44:     0x7fd753215da0 - <std[ebbe8e490f6d8018]::thread::lifecycle::spawn_unchecked<rustc_interface[29be6a7f2a5c93ab]::util::run_in_thread_with_globals<rustc_interface[29be6a7f2a5c93ab]::util::run_in_thread_pool_with_globals<rustc_interface[29be6a7f2a5c93ab]::interface::run_compiler<(), rustc_driver_impl[c03a371dcba30999]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e0039014fbc551a9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fd753216cac - <std[ebbe8e490f6d8018]::sys::thread::unix::Thread>::new::thread_start
  46:     0x7fd74cca597a - <unknown>
  47:     0x7fd74cd292bc - <unknown>
  48:                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 (981cf6947 2026-04-04) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `foo::{constant#0}`
#1 [sanitizer_settings_for] checking what set of sanitizers are enabled on `foo::{constant#0}`
#2 [sanitizer_settings_for] checking what set of sanitizers are enabled on `foo::{constant#0}::foo`
#3 [codegen_fn_attrs] computing codegen attributes of `foo::{constant#0}::foo`
#4 [lower_delayed_owner] lowering the delayed AST owner `foo::{constant#0}::foo`
#5 [hir_crate_items] getting HIR crate items
#6 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 5 previous errors

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

@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