Skip to content

[ICE]: mgca: No HirId for DefId #154539

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]
trait Iter<
    const FN: fn() = {
        || {
            use std::io::*;
            write!(_, "")
        }
    },
>
{
}

original:

#![feature(min_generic_const_args)]
trait Iter<
    const FN: fn() = {
        || {
            use std::io::*;
            write!(_, "")
        }
    },
>
{
}
fn main() {}

Version information

rustc 1.96.0-nightly (148adf223 2026-03-29)
binary: rustc
commit-hash: 148adf223edb0444eb1f99753919dd2080c2a534
commit-date: 2026-03-29
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

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

error: complex const arguments must be placed inside of a `const` block
 --> /tmp/icemaker_global_tempdir.gtjR7mSpPDPS/rustc_testrunner_tmpdir_reporting.jUQXCaNRBYM2/mvce.rs:4:9
  |
4 | /         || {
5 | |             use std::io::*;
6 | |             write!(_, "")
7 | |         }
  | |_________^

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

error: using function pointers as const generic parameters is forbidden
 --> /tmp/icemaker_global_tempdir.gtjR7mSpPDPS/rustc_testrunner_tmpdir_reporting.jUQXCaNRBYM2/mvce.rs:3:15
  |
3 |     const FN: fn() = {
  |               ^^^^
  |
  = note: the only supported types are integers, `bool`, and `char`

error: internal compiler error: /rustc-dev/148adf223edb0444eb1f99753919dd2080c2a534/compiler/rustc_middle/src/hir/mod.rs:478:32: No HirId for DefId(0:5 ~ mvce[777f]::Iter::{closure#0})


thread 'rustc' (3634809) panicked at /rustc-dev/148adf223edb0444eb1f99753919dd2080c2a534/compiler/rustc_middle/src/hir/mod.rs:478:32:
Box<dyn Any>
stack backtrace:
   0:     0x7f520ef8680b - <<std[321092190a068595]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[78175d3b44fe262f]::fmt::Display>::fmt
   1:     0x7f520f62f648 - core[78175d3b44fe262f]::fmt::write
   2:     0x7f520ef9d816 - <std[321092190a068595]::sys::stdio::unix::Stderr as std[321092190a068595]::io::Write>::write_fmt
   3:     0x7f520ef5c818 - std[321092190a068595]::panicking::default_hook::{closure#0}
   4:     0x7f520ef79c13 - std[321092190a068595]::panicking::default_hook
   5:     0x7f520df7e32c - std[321092190a068595]::panicking::update_hook::<alloc[aa3db4c38e3fedd6]::boxed::Box<rustc_driver_impl[60c97e9c0e13850d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f520ef79ef2 - std[321092190a068595]::panicking::panic_with_hook
   7:     0x7f520dfae1e1 - std[321092190a068595]::panicking::begin_panic::<rustc_errors[7e047add455c2402]::ExplicitBug>::{closure#0}
   8:     0x7f520dfa6c46 - std[321092190a068595]::sys::backtrace::__rust_end_short_backtrace::<std[321092190a068595]::panicking::begin_panic<rustc_errors[7e047add455c2402]::ExplicitBug>::{closure#0}, !>
   9:     0x7f520dfa4b48 - std[321092190a068595]::panicking::begin_panic::<rustc_errors[7e047add455c2402]::ExplicitBug>
  10:     0x7f520dfb9821 - <rustc_errors[7e047add455c2402]::diagnostic::BugAbort as rustc_errors[7e047add455c2402]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f520e59acf9 - rustc_middle[30dff145c64b4f0a]::util::bug::opt_span_bug_fmt::<rustc_span[de740248dc9e234b]::span_encoding::Span>::{closure#0}
  12:     0x7f520e59ae82 - rustc_middle[30dff145c64b4f0a]::ty::context::tls::with_opt::<rustc_middle[30dff145c64b4f0a]::util::bug::opt_span_bug_fmt<rustc_span[de740248dc9e234b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f520e58b44b - rustc_middle[30dff145c64b4f0a]::ty::context::tls::with_context_opt::<rustc_middle[30dff145c64b4f0a]::ty::context::tls::with_opt<rustc_middle[30dff145c64b4f0a]::util::bug::opt_span_bug_fmt<rustc_span[de740248dc9e234b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f520bcfd9d4 - rustc_middle[30dff145c64b4f0a]::util::bug::bug_fmt
  15:     0x7f520f71c713 - rustc_query_impl[4af9f80b8fc12ef7]::query_impl::local_def_id_to_hir_id::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7f520f71ba26 - rustc_query_impl[4af9f80b8fc12ef7]::execution::try_execute_query::<rustc_data_structures[ed5359664eeee2d9]::vec_cache::VecCache<rustc_span[de740248dc9e234b]::def_id::LocalDefId, rustc_middle[30dff145c64b4f0a]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[30dff145c64b4f0a]::dep_graph::graph::DepNodeIndex>, false>
  17:     0x7f520f71b785 - rustc_query_impl[4af9f80b8fc12ef7]::query_impl::local_def_id_to_hir_id::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7f520fd7da98 - <rustc_middle[30dff145c64b4f0a]::lint::ShallowLintLevelMap>::lint_level_id_at_node
  19:     0x7f520fd7ade0 - <rustc_middle[30dff145c64b4f0a]::ty::context::TyCtxt>::lint_level_at_node
  20:     0x7f520f71ad31 - rustc_hir_analysis[6338a0bcd6c3b359]::check_unused::check_unused_traits
  21:     0x7f521083ce89 - rustc_query_impl[4af9f80b8fc12ef7]::execution::try_execute_query::<rustc_middle[30dff145c64b4f0a]::query::caches::SingleCache<rustc_middle[30dff145c64b4f0a]::query::erase::ErasedData<[u8; 0usize]>>, false>
  22:     0x7f521083cb6d - rustc_query_impl[4af9f80b8fc12ef7]::query_impl::check_unused_traits::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f520f777ddd - rustc_hir_analysis[6338a0bcd6c3b359]::check_crate
  24:     0x7f520f718127 - rustc_interface[bfde3c9897c6f3bb]::passes::analysis
  25:     0x7f521083ce89 - rustc_query_impl[4af9f80b8fc12ef7]::execution::try_execute_query::<rustc_middle[30dff145c64b4f0a]::query::caches::SingleCache<rustc_middle[30dff145c64b4f0a]::query::erase::ErasedData<[u8; 0usize]>>, false>
  26:     0x7f521083cc69 - rustc_query_impl[4af9f80b8fc12ef7]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f521080c9e2 - rustc_interface[bfde3c9897c6f3bb]::interface::run_compiler::<(), rustc_driver_impl[60c97e9c0e13850d]::run_compiler::{closure#0}>::{closure#1}
  28:     0x7f52107f62fe - std[321092190a068595]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[bfde3c9897c6f3bb]::util::run_in_thread_with_globals<rustc_interface[bfde3c9897c6f3bb]::util::run_in_thread_pool_with_globals<rustc_interface[bfde3c9897c6f3bb]::interface::run_compiler<(), rustc_driver_impl[60c97e9c0e13850d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x7f52107f6ba0 - <std[321092190a068595]::thread::lifecycle::spawn_unchecked<rustc_interface[bfde3c9897c6f3bb]::util::run_in_thread_with_globals<rustc_interface[bfde3c9897c6f3bb]::util::run_in_thread_pool_with_globals<rustc_interface[bfde3c9897c6f3bb]::interface::run_compiler<(), rustc_driver_impl[60c97e9c0e13850d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[78175d3b44fe262f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7f52107f7a2c - <std[321092190a068595]::sys::thread::unix::Thread>::new::thread_start
  31:     0x7f520a2a597a - <unknown>
  32:     0x7f520a3292bc - <unknown>
  33:                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 (148adf223 2026-03-29) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `Iter::{closure#0}`
#1 [check_unused_traits] checking unused trait imports in crate
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-min_generic_const_args

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Mar 29, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)
    on Mar 29, 2026
  3. matthiaskrgr commented on Mar 29, 2026

    @matthiaskrgr
    MemberAuthor

    since #149136

  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 29, 2026
  5. mu001999 commented on Mar 30, 2026

    @mu001999
    Member

    @rustbot claim

  6. added 2 commits that reference this issue on Apr 16, 2026
  7. added a commit that references this issue on Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions