Skip to content

ICE expected leaf, got Value #150734

@matthiaskrgr

Description

@matthiaskrgr

Code

#![feature(min_generic_const_args, adt_const_params)]
use std::marker::ConstParamTy;
#[derive(Eq, PartialEq, ConstParamTy)]
struct Inner(u32);
#[derive(Eq, PartialEq, ConstParamTy)]
struct Outer(Inner);
fn with_outer<const O: Outer>() -> Outer {
    O
}
fn test<const N: u32>() {
    with_outer::<{ Outer(Outer(Inner)) }>();
}
fn main() {
    test::<5>()
}

Meta

rustc --version --verbose:

rustc 1.94.0-nightly (4d73a008e 2026-01-06)
binary: rustc
commit-hash: 4d73a008eaf6ba3ca067a3221e5c00602e33a5f2
commit-date: 2026-01-06
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Error output

<output>
Backtrace

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

error: internal compiler error: /rustc-dev/4d73a008eaf6ba3ca067a3221e5c00602e33a5f2/compiler/rustc_middle/src/ty/consts/valtree.rs:159:40: expected leaf, got Value { ty: u32, valtree: Branch([]) }


thread 'rustc' (2210474) panicked at /rustc-dev/4d73a008eaf6ba3ca067a3221e5c00602e33a5f2/compiler/rustc_middle/src/ty/consts/valtree.rs:159:40:
Box<dyn Any>
stack backtrace:
   0:     0x7ff0ef0215b3 - <<std[ddfe47d8d7a1475f]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a532a151b9e1489e]::fmt::Display>::fmt
   1:     0x7ff0ef60fa88 - core[a532a151b9e1489e]::fmt::write
   2:     0x7ff0ef037836 - <std[ddfe47d8d7a1475f]::sys::stdio::unix::Stderr as std[ddfe47d8d7a1475f]::io::Write>::write_fmt
   3:     0x7ff0eeff71a8 - std[ddfe47d8d7a1475f]::panicking::default_hook::{closure#0}
   4:     0x7ff0ef014e43 - std[ddfe47d8d7a1475f]::panicking::default_hook
   5:     0x7ff0edffa6ea - std[ddfe47d8d7a1475f]::panicking::update_hook::<alloc[61c3167de76b8e6f]::boxed::Box<rustc_driver_impl[7fdfd38a2830d21c]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff0ef015122 - std[ddfe47d8d7a1475f]::panicking::panic_with_hook
   7:     0x7ff0ee037001 - std[ddfe47d8d7a1475f]::panicking::begin_panic::<rustc_errors[4edd36428cf83490]::ExplicitBug>::{closure#0}
   8:     0x7ff0ee027666 - std[ddfe47d8d7a1475f]::sys::backtrace::__rust_end_short_backtrace::<std[ddfe47d8d7a1475f]::panicking::begin_panic<rustc_errors[4edd36428cf83490]::ExplicitBug>::{closure#0}, !>
   9:     0x7ff0ee02729f - std[ddfe47d8d7a1475f]::panicking::begin_panic::<rustc_errors[4edd36428cf83490]::ExplicitBug>
  10:     0x7ff0ee054d41 - <rustc_errors[4edd36428cf83490]::diagnostic::BugAbort as rustc_errors[4edd36428cf83490]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7ff0ee602ce9 - rustc_middle[5e24b05a5cc6fa51]::util::bug::opt_span_bug_fmt::<rustc_span[eb76c8861bbc8252]::span_encoding::Span>::{closure#0}
  12:     0x7ff0ee602e72 - rustc_middle[5e24b05a5cc6fa51]::ty::context::tls::with_opt::<rustc_middle[5e24b05a5cc6fa51]::util::bug::opt_span_bug_fmt<rustc_span[eb76c8861bbc8252]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7ff0ee5f3f8b - rustc_middle[5e24b05a5cc6fa51]::ty::context::tls::with_context_opt::<rustc_middle[5e24b05a5cc6fa51]::ty::context::tls::with_opt<rustc_middle[5e24b05a5cc6fa51]::util::bug::opt_span_bug_fmt<rustc_span[eb76c8861bbc8252]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7ff0ebb15e74 - rustc_middle[5e24b05a5cc6fa51]::util::bug::bug_fmt
  15:     0x7ff0f071b23a - rustc_const_eval[efa84d9f222e8d9d]::const_eval::valtrees::valtree_to_const_value
  16:     0x7ff0f071b5dd - rustc_const_eval[efa84d9f222e8d9d]::const_eval::valtrees::valtree_to_const_value
  17:     0x7ff0f071b5dd - rustc_const_eval[efa84d9f222e8d9d]::const_eval::valtrees::valtree_to_const_value
  18:     0x7ff0f071adeb - <rustc_const_eval[efa84d9f222e8d9d]::provide::{closure#1} as core[a532a151b9e1489e]::ops::function::FnOnce<(rustc_middle[5e24b05a5cc6fa51]::ty::context::TyCtxt, rustc_middle[5e24b05a5cc6fa51]::ty::consts::valtree::Value)>>::call_once
  19:     0x7ff0f071ad96 - rustc_query_impl[6cc0d79cca94585a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6cc0d79cca94585a]::query_impl::valtree_to_const_val::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e24b05a5cc6fa51]::query::erase::Erased<[u8; 24usize]>>
  20:     0x7ff0f071ad5f - <rustc_query_impl[6cc0d79cca94585a]::query_impl::valtree_to_const_val::dynamic_query::{closure#2} as core[a532a151b9e1489e]::ops::function::FnOnce<(rustc_middle[5e24b05a5cc6fa51]::ty::context::TyCtxt, rustc_middle[5e24b05a5cc6fa51]::ty::consts::valtree::Value)>>::call_once
  21:     0x7ff0f071a38c - rustc_query_system[dd105dbe8a673b02]::query::plumbing::try_execute_query::<rustc_query_impl[6cc0d79cca94585a]::DynamicConfig<rustc_query_system[dd105dbe8a673b02]::query::caches::DefaultCache<rustc_middle[5e24b05a5cc6fa51]::ty::consts::valtree::Value, rustc_middle[5e24b05a5cc6fa51]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[6cc0d79cca94585a]::plumbing::QueryCtxt, false>
  22:     0x7ff0f071a0a5 - rustc_query_impl[6cc0d79cca94585a]::query_impl::valtree_to_const_val::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7ff0f000dfb0 - rustc_monomorphize[971aa2a34d8f8606]::collector::items_of_instance
  24:     0x7ff0f000a232 - rustc_query_impl[6cc0d79cca94585a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6cc0d79cca94585a]::query_impl::items_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e24b05a5cc6fa51]::query::erase::Erased<[u8; 32usize]>>
  25:     0x7ff0f030c4d5 - rustc_query_system[dd105dbe8a673b02]::query::plumbing::try_execute_query::<rustc_query_impl[6cc0d79cca94585a]::DynamicConfig<rustc_query_system[dd105dbe8a673b02]::query::caches::DefaultCache<(rustc_middle[5e24b05a5cc6fa51]::ty::instance::Instance, rustc_middle[5e24b05a5cc6fa51]::mir::mono::CollectionMode), rustc_middle[5e24b05a5cc6fa51]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[6cc0d79cca94585a]::plumbing::QueryCtxt, false>
  26:     0x7ff0f030c0f3 - rustc_query_impl[6cc0d79cca94585a]::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7ff0f0ab8a94 - rustc_monomorphize[971aa2a34d8f8606]::collector::collect_items_rec
  28:     0x7ff0f0aba9e7 - rustc_monomorphize[971aa2a34d8f8606]::collector::collect_items_rec
  29:     0x7ff0f0aba9e7 - rustc_monomorphize[971aa2a34d8f8606]::collector::collect_items_rec
  30:     0x7ff0efa1dae1 - rustc_monomorphize[971aa2a34d8f8606]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  31:     0x7ff0efeb977a - rustc_monomorphize[971aa2a34d8f8606]::partitioning::collect_and_partition_mono_items
  32:     0x7ff0f0af45d6 - rustc_query_impl[6cc0d79cca94585a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6cc0d79cca94585a]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5e24b05a5cc6fa51]::query::erase::Erased<[u8; 24usize]>>
  33:     0x7ff0f0af459b - <rustc_query_impl[6cc0d79cca94585a]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[a532a151b9e1489e]::ops::function::FnOnce<(rustc_middle[5e24b05a5cc6fa51]::ty::context::TyCtxt, ())>>::call_once
  34:     0x7ff0f0af40f6 - rustc_query_system[dd105dbe8a673b02]::query::plumbing::try_execute_query::<rustc_query_impl[6cc0d79cca94585a]::DynamicConfig<rustc_query_system[dd105dbe8a673b02]::query::caches::SingleCache<rustc_middle[5e24b05a5cc6fa51]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[6cc0d79cca94585a]::plumbing::QueryCtxt, false>
  35:     0x7ff0f0af3e9b - rustc_query_impl[6cc0d79cca94585a]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7ff0f09efc8a - rustc_codegen_ssa[8ed2eee97b550a4f]::base::codegen_crate::<rustc_codegen_llvm[da7f0496a594b3e7]::LlvmCodegenBackend>
  37:     0x7ff0f09ed77d - <rustc_codegen_llvm[da7f0496a594b3e7]::LlvmCodegenBackend as rustc_codegen_ssa[8ed2eee97b550a4f]::traits::backend::CodegenBackend>::codegen_crate
  38:     0x7ff0f0979e8f - <rustc_interface[9980b4cb58bb210e]::queries::Linker>::codegen_and_build_linker
  39:     0x7ff0f097749c - <rustc_interface[9980b4cb58bb210e]::passes::create_and_enter_global_ctxt<core[a532a151b9e1489e]::option::Option<rustc_interface[9980b4cb58bb210e]::queries::Linker>, rustc_driver_impl[7fdfd38a2830d21c]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[a532a151b9e1489e]::ops::function::FnOnce<(&rustc_session[e5d95afd4a4e27ed]::session::Session, rustc_middle[5e24b05a5cc6fa51]::ty::context::CurrentGcx, alloc[61c3167de76b8e6f]::sync::Arc<rustc_data_structures[fe3ac7cdd49a0dd4]::jobserver::Proxy>, &std[ddfe47d8d7a1475f]::sync::once_lock::OnceLock<rustc_middle[5e24b05a5cc6fa51]::ty::context::GlobalCtxt>, &rustc_data_structures[fe3ac7cdd49a0dd4]::sync::worker_local::WorkerLocal<rustc_middle[5e24b05a5cc6fa51]::arena::Arena>, &rustc_data_structures[fe3ac7cdd49a0dd4]::sync::worker_local::WorkerLocal<rustc_hir[8c63d784b395ad98]::Arena>, rustc_driver_impl[7fdfd38a2830d21c]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  40:     0x7ff0f085dc58 - rustc_interface[9980b4cb58bb210e]::interface::run_compiler::<(), rustc_driver_impl[7fdfd38a2830d21c]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7ff0f070cace - std[ddfe47d8d7a1475f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9980b4cb58bb210e]::util::run_in_thread_with_globals<rustc_interface[9980b4cb58bb210e]::util::run_in_thread_pool_with_globals<rustc_interface[9980b4cb58bb210e]::interface::run_compiler<(), rustc_driver_impl[7fdfd38a2830d21c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7ff0f070c8a0 - <std[ddfe47d8d7a1475f]::thread::lifecycle::spawn_unchecked<rustc_interface[9980b4cb58bb210e]::util::run_in_thread_with_globals<rustc_interface[9980b4cb58bb210e]::util::run_in_thread_pool_with_globals<rustc_interface[9980b4cb58bb210e]::interface::run_compiler<(), rustc_driver_impl[7fdfd38a2830d21c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a532a151b9e1489e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7ff0f070ac78 - <std[ddfe47d8d7a1475f]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7ff0ea09698b - <unknown>
  45:     0x7ff0ea11a9cc - <unknown>
  46:                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 `/tmp/im/rustc-ice-2026-01-06T20_55_29-2210445.txt` to your bug report

note: rustc 1.94.0-nightly (4d73a008e 2026-01-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to MIR constant value
#1 [items_of_instance] collecting items used by `with_outer::<ValTree(Branch([ValTree(Branch([ValTree(Branch([]): Inner)]): Outer)]): Outer)>`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

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