rust-lang / rust-lang/rust

[ICE]: `No HirId for DefId`

Open
#155,482 4 comments 0 reactions 1 assignee View on GitHub

@TaKO8Ki is already working on this.

Since Apr 20, 2026.

C-bug I-ICE S-bug-has-test S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

#![feature(generic_assert)]
fn main() {
    const I = 0; 
    std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {
        assert!(N != 0);
    });
}

original:

fn main() {
    const I = 0; // type ommitted
    std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {
        assert!(N != 0);
    });
}

Version information

rustc 1.97.0-nightly (7a38981b3 2026-04-18)
binary: rustc
commit-hash: 7a38981b365e4c3672053b910fce9a14c6555ab9
commit-date: 2026-04-18
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Possibly related line of code:
https://github.com/rust-lang/rust/blob/7a38981b365e4c3672053b910fce9a14c6555ab9/compiler/rustc_middle/src/hir/mod.rs#L456-L468

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_assert)

Program output

error[E0425]: cannot find value `N` in this scope
 --> /tmp/icemaker_global_tempdir.IhtCXfU72lIg/rustc_testrunner_tmpdir_reporting.e3BRcnWbJjOC/mvce.rs:4:17
  |
2 |     const I = 0; 
  |     ------------ similarly named constant `I` defined here
3 |     std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {
4 |         assert!(N != 0);
  |                 ^
  |
help: a constant with a similar name exists
  |
4 -         assert!(N != 0);
4 +         assert!(I != 0);
  |

error: invalid argument to a legacy const generic: cannot have const blocks, closures, async blocks or items
 --> /tmp/icemaker_global_tempdir.IhtCXfU72lIg/rustc_testrunner_tmpdir_reporting.e3BRcnWbJjOC/mvce.rs:3:57
  |
3 |       std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {
  |  _________________________________________________________^
4 | |         assert!(N != 0);
5 | |     });
  | |_____^

error: missing type for `const` item
 --> /tmp/icemaker_global_tempdir.IhtCXfU72lIg/rustc_testrunner_tmpdir_reporting.e3BRcnWbJjOC/mvce.rs:2:12
  |
2 |     const I = 0; 
  |            ^ help: provide a type for the constant: `: i32`

warning: unreachable expression
 --> /tmp/icemaker_global_tempdir.IhtCXfU72lIg/rustc_testrunner_tmpdir_reporting.e3BRcnWbJjOC/mvce.rs:3:48
  |
3 |     std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const {
  |                                       -------  ^^^^^^^ unreachable expression
  |                                       |
  |                                       any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/7a38981b365e4c3672053b910fce9a14c6555ab9/compiler/rustc_middle/src/hir/mod.rs:462:32: No HirId for DefId(0:5 ~ mvce[cf05]::main::{constant#0})


thread 'rustc' (1713790) panicked at /rustc-dev/7a38981b365e4c3672053b910fce9a14c6555ab9/compiler/rustc_middle/src/hir/mod.rs:462:32:
Box<dyn Any>
stack backtrace:
   0:     0x7f80db41a16b - <<std[9a59d2b2593658e8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e4bb62eb9d7a9f86]::fmt::Display>::fmt
   1:     0x7f80dba2e5d6 - core[e4bb62eb9d7a9f86]::fmt::write
   2:     0x7f80db431166 - <std[9a59d2b2593658e8]::sys::stdio::unix::Stderr as std[9a59d2b2593658e8]::io::Write>::write_fmt
   3:     0x7f80db3f0448 - std[9a59d2b2593658e8]::panicking::default_hook::{closure#0}
   4:     0x7f80db40d7d3 - std[9a59d2b2593658e8]::panicking::default_hook
   5:     0x7f80da3e35fc - std[9a59d2b2593658e8]::panicking::update_hook::<alloc[a3219106322e8289]::boxed::Box<rustc_driver_impl[22caf4810f623222]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f80db40dab2 - std[9a59d2b2593658e8]::panicking::panic_with_hook
   7:     0x7f80da413561 - std[9a59d2b2593658e8]::panicking::begin_panic::<rustc_errors[23646e0ffc3110bb]::ExplicitBug>::{closure#0}
   8:     0x7f80da40c136 - std[9a59d2b2593658e8]::sys::backtrace::__rust_end_short_backtrace::<std[9a59d2b2593658e8]::panicking::begin_panic<rustc_errors[23646e0ffc3110bb]::ExplicitBug>::{closure#0}, !>
   9:     0x7f80da409ed8 - std[9a59d2b2593658e8]::panicking::begin_panic::<rustc_errors[23646e0ffc3110bb]::ExplicitBug>
  10:     0x7f80da41eb11 - <rustc_errors[23646e0ffc3110bb]::diagnostic::BugAbort as rustc_errors[23646e0ffc3110bb]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f80daa173b9 - rustc_middle[56f1549a6b8ca02f]::util::bug::opt_span_bug_fmt::<rustc_span[e5f1c308f2f54214]::span_encoding::Span>::{closure#0}
  12:     0x7f80daa17542 - rustc_middle[56f1549a6b8ca02f]::ty::context::tls::with_opt::<rustc_middle[56f1549a6b8ca02f]::util::bug::opt_span_bug_fmt<rustc_span[e5f1c308f2f54214]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f80daa0835b - rustc_middle[56f1549a6b8ca02f]::ty::context::tls::with_context_opt::<rustc_middle[56f1549a6b8ca02f]::ty::context::tls::with_opt<rustc_middle[56f1549a6b8ca02f]::util::bug::opt_span_bug_fmt<rustc_span[e5f1c308f2f54214]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f80d7b2f894 - rustc_middle[56f1549a6b8ca02f]::util::bug::bug_fmt
  15:     0x7f80dbb5de93 - rustc_query_impl[f194054d0e0bcd32]::query_impl::local_def_id_to_hir_id::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7f80dbb5d166 - rustc_query_impl[f194054d0e0bcd32]::execution::try_execute_query::<rustc_data_structures[2a30707b8dfb3dad]::vec_cache::VecCache<rustc_span[e5f1c308f2f54214]::def_id::LocalDefId, rustc_middle[56f1549a6b8ca02f]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[56f1549a6b8ca02f]::dep_graph::graph::DepNodeIndex>, false>
  17:     0x7f80dbb5cec5 - rustc_query_impl[f194054d0e0bcd32]::query_impl::local_def_id_to_hir_id::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7f80dc3eb579 - <rustc_middle[56f1549a6b8ca02f]::lint::ShallowLintLevelMap>::lint_level_id_at_node
  19:     0x7f80dc3dba20 - <rustc_lint[1139734790e8c56]::levels::LintLevelsBuilder<rustc_lint[1139734790e8c56]::levels::LintLevelQueryMap>>::add_id
  20:     0x7f80dbef8de0 - rustc_lint[1139734790e8c56]::levels::shallow_lint_levels_on
  21:     0x7f80dbef89f0 - rustc_query_impl[f194054d0e0bcd32]::query_impl::shallow_lint_levels_on::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f80dbef7726 - rustc_query_impl[f194054d0e0bcd32]::execution::try_execute_query::<rustc_data_structures[2a30707b8dfb3dad]::vec_cache::VecCache<rustc_hir_id[db5e56b5e091479c]::OwnerId, rustc_middle[56f1549a6b8ca02f]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[56f1549a6b8ca02f]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7f80dbef73c5 - rustc_query_impl[f194054d0e0bcd32]::query_impl::shallow_lint_levels_on::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f80dc3e89fe - <rustc_middle[56f1549a6b8ca02f]::ty::context::TyCtxt>::lint_level_at_node
  25:     0x7f80dbb5c3b1 - rustc_hir_analysis[ecb4893f6fa9c77d]::check_unused::check_unused_traits
  26:     0x7f80dcbd3649 - rustc_query_impl[f194054d0e0bcd32]::execution::try_execute_query::<rustc_middle[56f1549a6b8ca02f]::query::caches::SingleCache<rustc_middle[56f1549a6b8ca02f]::query::erase::ErasedData<[u8; 0usize]>>, false>
  27:     0x7f80dcbd3329 - rustc_query_impl[f194054d0e0bcd32]::query_impl::check_unused_traits::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7f80dbfb981f - rustc_hir_analysis[ecb4893f6fa9c77d]::check_crate
  29:     0x7f80dc90f6a7 - rustc_interface[daae88cdf280a8bc]::passes::analysis
  30:     0x7f80dcbd3649 - rustc_query_impl[f194054d0e0bcd32]::execution::try_execute_query::<rustc_middle[56f1549a6b8ca02f]::query::caches::SingleCache<rustc_middle[56f1549a6b8ca02f]::query::erase::ErasedData<[u8; 0usize]>>, false>
  31:     0x7f80dcbd32a9 - rustc_query_impl[f194054d0e0bcd32]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7f80dcbaf976 - rustc_interface[daae88cdf280a8bc]::interface::run_compiler::<(), rustc_driver_impl[22caf4810f623222]::run_compiler::{closure#0}>::{closure#1}
  33:     0x7f80dcb8b74a - std[9a59d2b2593658e8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[daae88cdf280a8bc]::util::run_in_thread_with_globals<rustc_interface[daae88cdf280a8bc]::util::run_in_thread_pool_with_globals<rustc_interface[daae88cdf280a8bc]::interface::run_compiler<(), rustc_driver_impl[22caf4810f623222]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7f80dcb8be2d - <std[9a59d2b2593658e8]::thread::lifecycle::spawn_unchecked<rustc_interface[daae88cdf280a8bc]::util::run_in_thread_with_globals<rustc_interface[daae88cdf280a8bc]::util::run_in_thread_pool_with_globals<rustc_interface[daae88cdf280a8bc]::interface::run_compiler<(), rustc_driver_impl[22caf4810f623222]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e4bb62eb9d7a9f86]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f80dcb8ccac - <std[9a59d2b2593658e8]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7f80d66a597a - <unknown>
  37:     0x7f80d67292bc - <unknown>
  38:                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.97.0-nightly (7a38981b3 2026-04-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_assert) -Z dump-mir-dir=dir

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `main::{constant#0}`
#1 [shallow_lint_levels_on] looking up lint levels for `main::{constant#0}::{use#1}`
#2 [check_unused_traits] checking unused trait imports in crate
#3 [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 E0425`.

@rustbot label +F-generic_assert

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.