Skip to content

ICE: can't type-check body of DefId #150956

@matthiaskrgr

Description

@matthiaskrgr

Code

#![feature(min_generic_const_args)]
#[type_const]
pub const TYPE_CONST : usize = 1;
fn main() {}

Meta

rustc --version --verbose:

rustc 1.94.0-nightly (9bc8b40bc 2026-01-11)
binary: rustc
commit-hash: 9bc8b40bc314b74e1d5e5ab21a0df39c55a34806
commit-date: 2026-01-11
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Error output

<output>
Backtrace

error: internal compiler error: /rustc-dev/9bc8b40bc314b74e1d5e5ab21a0df39c55a34806/compiler/rustc_hir_typeck/src/lib.rs:124:9: can't type-check body of DefId(0:3 ~ code[82d0]::TYPE_CONST)
 --> code.rs:3:1
  |
3 | pub const TYPE_CONST : usize = 1;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (3956630) panicked at /rustc-dev/9bc8b40bc314b74e1d5e5ab21a0df39c55a34806/compiler/rustc_hir_typeck/src/lib.rs:124:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f5aa2640913 - <<std[99c140e4e2f4f9ef]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a7af9ee465f2ca90]::fmt::Display>::fmt
   1:     0x7f5aa2c0e388 - core[a7af9ee465f2ca90]::fmt::write
   2:     0x7f5aa2656b96 - <std[99c140e4e2f4f9ef]::sys::stdio::unix::Stderr as std[99c140e4e2f4f9ef]::io::Write>::write_fmt
   3:     0x7f5aa2616ae8 - std[99c140e4e2f4f9ef]::panicking::default_hook::{closure#0}
   4:     0x7f5aa26341a3 - std[99c140e4e2f4f9ef]::panicking::default_hook
   5:     0x7f5aa1616d7a - std[99c140e4e2f4f9ef]::panicking::update_hook::<alloc[9f2146c2268314c9]::boxed::Box<rustc_driver_impl[ae151fd32d86d2bb]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f5aa2634482 - std[99c140e4e2f4f9ef]::panicking::panic_with_hook
   7:     0x7f5aa1653a61 - std[99c140e4e2f4f9ef]::panicking::begin_panic::<rustc_errors[a6fb4176bd7f3797]::ExplicitBug>::{closure#0}
   8:     0x7f5aa1643e26 - std[99c140e4e2f4f9ef]::sys::backtrace::__rust_end_short_backtrace::<std[99c140e4e2f4f9ef]::panicking::begin_panic<rustc_errors[a6fb4176bd7f3797]::ExplicitBug>::{closure#0}, !>
   9:     0x7f5aa164152c - std[99c140e4e2f4f9ef]::panicking::begin_panic::<rustc_errors[a6fb4176bd7f3797]::ExplicitBug>
  10:     0x7f5aa1671761 - <rustc_errors[a6fb4176bd7f3797]::diagnostic::BugAbort as rustc_errors[a6fb4176bd7f3797]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f5aa1bfff4c - <rustc_errors[a6fb4176bd7f3797]::DiagCtxtHandle>::span_bug::<rustc_span[a720842ac7aa27fd]::span_encoding::Span, alloc[9f2146c2268314c9]::string::String>
  12:     0x7f5aa1c22aa6 - rustc_middle[e8c837d2bbdd4436]::util::bug::opt_span_bug_fmt::<rustc_span[a720842ac7aa27fd]::span_encoding::Span>::{closure#0}
  13:     0x7f5aa1c22c52 - rustc_middle[e8c837d2bbdd4436]::ty::context::tls::with_opt::<rustc_middle[e8c837d2bbdd4436]::util::bug::opt_span_bug_fmt<rustc_span[a720842ac7aa27fd]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f5aa1c1427b - rustc_middle[e8c837d2bbdd4436]::ty::context::tls::with_context_opt::<rustc_middle[e8c837d2bbdd4436]::ty::context::tls::with_opt<rustc_middle[e8c837d2bbdd4436]::util::bug::opt_span_bug_fmt<rustc_span[a720842ac7aa27fd]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f5a9fc4eba8 - rustc_middle[e8c837d2bbdd4436]::util::bug::span_bug_fmt::<rustc_span[a720842ac7aa27fd]::span_encoding::Span>
  16:     0x7f5aa013936b - rustc_hir_typeck[ad7f8f38f9edc192]::typeck_with_inspect::{closure#0}::{closure#0}
  17:     0x7f5aa39610f8 - rustc_hir_typeck[ad7f8f38f9edc192]::typeck_with_inspect::{closure#0}
  18:     0x7f5aa395b8b4 - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>>
  19:     0x7f5aa2e31377 - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_data_structures[fd66fb9278fe12bc]::vec_cache::VecCache<rustc_span[a720842ac7aa27fd]::def_id::LocalDefId, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[939a27e7c73d5201]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  20:     0x7f5aa2e30c49 - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7f5aa3182049 - rustc_mir_build[e9d4407ab8fac66a]::thir::pattern::check_match::check_match
  22:     0x7f5aa318140b - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 1usize]>>
  23:     0x7f5aa32dca6d - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_data_structures[fd66fb9278fe12bc]::vec_cache::VecCache<rustc_span[a720842ac7aa27fd]::def_id::LocalDefId, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[939a27e7c73d5201]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  24:     0x7f5aa32dc691 - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f5aa30cc8a5 - rustc_mir_build[e9d4407ab8fac66a]::builder::build_mir
  26:     0x7f5aa2c08ea9 - rustc_mir_transform[8fb825047ac7af67]::mir_built
  27:     0x7f5aa2c08e73 - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f5aa2e31377 - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_data_structures[fd66fb9278fe12bc]::vec_cache::VecCache<rustc_span[a720842ac7aa27fd]::def_id::LocalDefId, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[939a27e7c73d5201]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  29:     0x7f5aa2e30dc9 - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f5aa2d909c1 - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::trivial_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 32usize]>>
  31:     0x7f5aa2d8e06c - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_query_system[939a27e7c73d5201]::query::caches::DefIdCache<rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  32:     0x7f5aa2d8d8e0 - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::trivial_const::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7f5aa3cbdd0e - rustc_const_eval[4a5e6181bc613dc7]::const_eval::eval_queries::eval_to_allocation_raw_provider
  34:     0x7f5aa3cbac46 - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 24usize]>>
  35:     0x7f5aa3cba39f - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_query_system[939a27e7c73d5201]::query::caches::DefaultCache<rustc_middle[e8c837d2bbdd4436]::ty::PseudoCanonicalInput<rustc_middle[e8c837d2bbdd4436]::mir::interpret::GlobalId>, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  36:     0x7f5aa3cb9f49 - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f5aa30f59b1 - <rustc_middle[e8c837d2bbdd4436]::ty::context::TyCtxt>::const_eval_poly_to_alloc
  38:     0x7f5aa2dc86f3 - rustc_passes[39a338168e9bcf26]::reachable::reachable_set
  39:     0x7f5aa3da5ee2 - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::reachable_set::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>>
  40:     0x7f5aa3da3f1d - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_query_system[939a27e7c73d5201]::query::caches::SingleCache<rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  41:     0x7f5aa3da369e - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::reachable_set::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f5aa2f7d8ed - rustc_codegen_ssa[fad5119e1b07ba68]::back::symbol_export::reachable_non_generics_provider
  43:     0x7f5aa3c95fac - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::reachable_non_generics::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>>
  44:     0x7f5aa2e28277 - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_data_structures[fd66fb9278fe12bc]::vec_cache::VecCache<rustc_span[a720842ac7aa27fd]::def_id::CrateNum, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[939a27e7c73d5201]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  45:     0x7f5aa32cfc89 - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::reachable_non_generics::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f5aa3657e79 - rustc_codegen_ssa[fad5119e1b07ba68]::back::symbol_export::exported_non_generic_symbols_provider_local
  47:     0x7f5aa3b2d573 - rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::exported_non_generic_symbols::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 16usize]>>
  48:     0x7f5aa3b2d549 - <rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::exported_non_generic_symbols::dynamic_query::{closure#2} as core[a7af9ee465f2ca90]::ops::function::FnOnce<(rustc_middle[e8c837d2bbdd4436]::ty::context::TyCtxt, rustc_span[a720842ac7aa27fd]::def_id::CrateNum)>>::call_once
  49:     0x7f5aa3b2b8e6 - rustc_query_system[939a27e7c73d5201]::query::plumbing::try_execute_query::<rustc_query_impl[8d2dd2d4cb4cfb4c]::DynamicConfig<rustc_data_structures[fd66fb9278fe12bc]::vec_cache::VecCache<rustc_span[a720842ac7aa27fd]::def_id::CrateNum, rustc_middle[e8c837d2bbdd4436]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[939a27e7c73d5201]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8d2dd2d4cb4cfb4c]::plumbing::QueryCtxt, false>
  50:     0x7f5aa3b2b34c - rustc_query_impl[8d2dd2d4cb4cfb4c]::query_impl::exported_non_generic_symbols::get_query_non_incr::__rust_end_short_backtrace
  51:     0x7f5aa3b30ec3 - <rustc_codegen_ssa[fad5119e1b07ba68]::CrateInfo>::new
  52:     0x7f5aa401bcd6 - rustc_codegen_ssa[fad5119e1b07ba68]::base::codegen_crate::<rustc_codegen_llvm[73aaf3788d3212b1]::LlvmCodegenBackend>
  53:     0x7f5aa401b943 - <rustc_codegen_llvm[73aaf3788d3212b1]::LlvmCodegenBackend as rustc_codegen_ssa[fad5119e1b07ba68]::traits::backend::CodegenBackend>::codegen_crate
  54:     0x7f5aa3f95bcf - <rustc_interface[520cd77b57dda632]::queries::Linker>::codegen_and_build_linker
  55:     0x7f5aa3f931dc - <rustc_interface[520cd77b57dda632]::passes::create_and_enter_global_ctxt<core[a7af9ee465f2ca90]::option::Option<rustc_interface[520cd77b57dda632]::queries::Linker>, rustc_driver_impl[ae151fd32d86d2bb]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[a7af9ee465f2ca90]::ops::function::FnOnce<(&rustc_session[df97837b9831b2c7]::session::Session, rustc_middle[e8c837d2bbdd4436]::ty::context::CurrentGcx, alloc[9f2146c2268314c9]::sync::Arc<rustc_data_structures[fd66fb9278fe12bc]::jobserver::Proxy>, &std[99c140e4e2f4f9ef]::sync::once_lock::OnceLock<rustc_middle[e8c837d2bbdd4436]::ty::context::GlobalCtxt>, &rustc_data_structures[fd66fb9278fe12bc]::sync::worker_local::WorkerLocal<rustc_middle[e8c837d2bbdd4436]::arena::Arena>, &rustc_data_structures[fd66fb9278fe12bc]::sync::worker_local::WorkerLocal<rustc_hir[cff0cb0f93fd5145]::Arena>, rustc_driver_impl[ae151fd32d86d2bb]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  56:     0x7f5aa3e2e218 - rustc_interface[520cd77b57dda632]::interface::run_compiler::<(), rustc_driver_impl[ae151fd32d86d2bb]::run_compiler::{closure#0}>::{closure#1}
  57:     0x7f5aa3d5d64e - std[99c140e4e2f4f9ef]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[520cd77b57dda632]::util::run_in_thread_with_globals<rustc_interface[520cd77b57dda632]::util::run_in_thread_pool_with_globals<rustc_interface[520cd77b57dda632]::interface::run_compiler<(), rustc_driver_impl[ae151fd32d86d2bb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  58:     0x7f5aa3d5d420 - <std[99c140e4e2f4f9ef]::thread::lifecycle::spawn_unchecked<rustc_interface[520cd77b57dda632]::util::run_in_thread_with_globals<rustc_interface[520cd77b57dda632]::util::run_in_thread_pool_with_globals<rustc_interface[520cd77b57dda632]::interface::run_compiler<(), rustc_driver_impl[ae151fd32d86d2bb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a7af9ee465f2ca90]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  59:     0x7f5aa3d5f238 - <std[99c140e4e2f4f9ef]::sys::thread::unix::Thread>::new::thread_start
  60:     0x7f5a9d69698b - <unknown>
  61:     0x7f5a9d71a9cc - <unknown>
  62:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-01-11T08_35_51-3956603.txt` to your bug report

note: rustc 1.94.0-nightly (9bc8b40bc 2026-01-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `TYPE_CONST`
#1 [check_match] match-checking `TYPE_CONST`
#2 [mir_built] building MIR for `TYPE_CONST`
#3 [trivial_const] checking if `TYPE_CONST` is a trivial const
#4 [eval_to_allocation_raw] const-evaluating + checking `TYPE_CONST`
#5 [reachable_set] reachability
#6 [reachable_non_generics] looking up the exported symbols of a crate
#7 [exported_non_generic_symbols] collecting exported non-generic symbols for crate `0`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions