Skip to content

ICE: mgca: No HirId for DefId #149977

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --crate-type=lib
#![feature(min_generic_const_args)]
fn foo<const N: usize, const K: usize>() -> [u32; K] {
    [0; K]
}

original:

//@ ignore-auxiliary (used by `./allow-in-other-module.rs`)

// This should not warn.
#![allow(not_a_real_lint)]

// This should not warn, either.
fn foo<const N: usize, const K: usize>(_data: [u32; N]) -> [u32; K] {
    [0; K]
}

Version information

rustc 1.94.0-nightly (3f4dc1e02 2025-12-14)
binary: rustc
commit-hash: 3f4dc1e02d759aa3c3807d4efc1f7f6e293536a5
commit-date: 2025-12-14
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.5

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(()).owners[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(()).owners.get(id)?.as_owner().map(|i| &i.nodes);
providers.hir_owner_parent = |tcx, owner_id| {
tcx.opt_local_parent(owner_id.def_id).map_or(CRATE_HIR_ID, |parent_def_id| {
let parent_owner_id = tcx.local_def_id_to_hir_id(parent_def_id).owner;

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(min_generic_const_args) --crate-type=lib

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: function `foo` is never used
 --> /tmp/icemaker_global_tempdir.U3pUa92njTMT/rustc_testrunner_tmpdir_reporting.EHEsm5rsaJxS/mvce.rs:1:4
  |
1 | fn foo<const N: usize, const K: usize>() -> [u32; K] {
  |    ^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: compiler/rustc_middle/src/hir/mod.rs:384:32: No HirId for DefId(0:6 ~ mvce[3999]::foo::{constant#0})


thread 'rustc' (2689906) panicked at compiler/rustc_middle/src/hir/mod.rs:384:32:
Box<dyn Any>
stack backtrace:
   0:     0x7faba2190173 - <<std[e49fa185a119b89b]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[17865207963548b5]::fmt::Display>::fmt
   1:     0x7faba2810648 - core[17865207963548b5]::fmt::write
   2:     0x7faba21a67c6 - <std[e49fa185a119b89b]::sys::stdio::unix::Stderr as std[e49fa185a119b89b]::io::Write>::write_fmt
   3:     0x7faba2166938 - std[e49fa185a119b89b]::panicking::default_hook::{closure#0}
   4:     0x7faba2184043 - std[e49fa185a119b89b]::panicking::default_hook
   5:     0x7faba11741d7 - std[e49fa185a119b89b]::panicking::update_hook::<alloc[756b9f94e2773738]::boxed::Box<rustc_driver_impl[e1c4671be5271ce8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7faba2184322 - std[e49fa185a119b89b]::panicking::panic_with_hook
   7:     0x7faba11b0c61 - std[e49fa185a119b89b]::panicking::begin_panic::<rustc_errors[c34899de065ee3bb]::ExplicitBug>::{closure#0}
   8:     0x7faba11a12b6 - std[e49fa185a119b89b]::sys::backtrace::__rust_end_short_backtrace::<std[e49fa185a119b89b]::panicking::begin_panic<rustc_errors[c34899de065ee3bb]::ExplicitBug>::{closure#0}, !>
   9:     0x7faba11a0efa - std[e49fa185a119b89b]::panicking::begin_panic::<rustc_errors[c34899de065ee3bb]::ExplicitBug>
  10:     0x7faba11ce351 - <rustc_errors[c34899de065ee3bb]::diagnostic::BugAbort as rustc_errors[c34899de065ee3bb]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7faba1771e09 - rustc_middle[7055997c00c0bb98]::util::bug::opt_span_bug_fmt::<rustc_span[ce53af16555a42ff]::span_encoding::Span>::{closure#0}
  12:     0x7faba1771f92 - rustc_middle[7055997c00c0bb98]::ty::context::tls::with_opt::<rustc_middle[7055997c00c0bb98]::util::bug::opt_span_bug_fmt<rustc_span[ce53af16555a42ff]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7faba176376b - rustc_middle[7055997c00c0bb98]::ty::context::tls::with_context_opt::<rustc_middle[7055997c00c0bb98]::ty::context::tls::with_opt<rustc_middle[7055997c00c0bb98]::util::bug::opt_span_bug_fmt<rustc_span[ce53af16555a42ff]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fab9fc6b994 - rustc_middle[7055997c00c0bb98]::util::bug::bug_fmt
  15:     0x7faba28f3a47 - rustc_query_impl[462c6a5584cea8d4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[462c6a5584cea8d4]::query_impl::local_def_id_to_hir_id::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 8usize]>>
  16:     0x7faba28f2e37 - rustc_query_system[5be0c069f6d5c539]::query::plumbing::try_execute_query::<rustc_query_impl[462c6a5584cea8d4]::DynamicConfig<rustc_data_structures[30161969bbcb553f]::vec_cache::VecCache<rustc_span[ce53af16555a42ff]::def_id::LocalDefId, rustc_middle[7055997c00c0bb98]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5be0c069f6d5c539]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[462c6a5584cea8d4]::plumbing::QueryCtxt, false>
  17:     0x7faba28f2b8b - rustc_query_impl[462c6a5584cea8d4]::query_impl::local_def_id_to_hir_id::get_query_non_incr::__rust_end_short_backtrace
  18:     0x7faba323692e - <rustc_metadata[2002d9e21ce78884]::rmeta::encoder::EncodeContext>::encode_def_ids
  19:     0x7faba324f4df - <rustc_metadata[2002d9e21ce78884]::rmeta::encoder::EncodeContext>::encode_crate_root
  20:     0x7faba3c2b32a - <rustc_metadata[2002d9e21ce78884]::rmeta::encoder::encode_metadata::{closure#3} as core[17865207963548b5]::ops::function::FnOnce<(rustc_middle[7055997c00c0bb98]::ty::context::TyCtxt, &std[e49fa185a119b89b]::path::Path)>>::call_once
  21:     0x7faba3c28553 - rustc_metadata[2002d9e21ce78884]::rmeta::encoder::encode_metadata
  22:     0x7faba3923781 - rustc_metadata[2002d9e21ce78884]::fs::encode_and_write_metadata
  23:     0x7faba3b30125 - <rustc_interface[50af632e35c6bce3]::queries::Linker>::codegen_and_build_linker
  24:     0x7faba3b2ce9c - <rustc_interface[50af632e35c6bce3]::passes::create_and_enter_global_ctxt<core[17865207963548b5]::option::Option<rustc_interface[50af632e35c6bce3]::queries::Linker>, rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[17865207963548b5]::ops::function::FnOnce<(&rustc_session[307f8e7a4263bd4]::session::Session, rustc_middle[7055997c00c0bb98]::ty::context::CurrentGcx, alloc[756b9f94e2773738]::sync::Arc<rustc_data_structures[30161969bbcb553f]::jobserver::Proxy>, &std[e49fa185a119b89b]::sync::once_lock::OnceLock<rustc_middle[7055997c00c0bb98]::ty::context::GlobalCtxt>, &rustc_data_structures[30161969bbcb553f]::sync::worker_local::WorkerLocal<rustc_middle[7055997c00c0bb98]::arena::Arena>, &rustc_data_structures[30161969bbcb553f]::sync::worker_local::WorkerLocal<rustc_hir[5d00f225b65c0257]::Arena>, rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  25:     0x7faba39c19da - rustc_interface[50af632e35c6bce3]::interface::run_compiler::<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7faba3931d8e - std[e49fa185a119b89b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[50af632e35c6bce3]::util::run_in_thread_with_globals<rustc_interface[50af632e35c6bce3]::util::run_in_thread_pool_with_globals<rustc_interface[50af632e35c6bce3]::interface::run_compiler<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7faba3931b60 - <std[e49fa185a119b89b]::thread::lifecycle::spawn_unchecked<rustc_interface[50af632e35c6bce3]::util::run_in_thread_with_globals<rustc_interface[50af632e35c6bce3]::util::run_in_thread_pool_with_globals<rustc_interface[50af632e35c6bce3]::interface::run_compiler<(), rustc_driver_impl[e1c4671be5271ce8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[17865207963548b5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7faba39374f8 - <std[e49fa185a119b89b]::sys::thread::unix::Thread>::new::thread_start
  29:     0x7fab9d2969cb - <unknown>
  30:     0x7fab9d31aa0c - <unknown>
  31:                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.94.0-nightly (3f4dc1e02 2025-12-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(min_generic_const_args) --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `foo::{constant#0}`
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted


@rustbot label +F-min_generic_const_args

since dc47a69

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`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