Skip to content

[ICE]: unexpected const kind #158428

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(min_generic_const_args)]
#![feature(generic_const_args)]
#![feature(generic_const_exprs)]
union AsBytes<T> {
    as_bytes: [u8; const { size_of::<T>() }],
}

original:

#![feature(min_generic_const_args)]
#![feature(generic_const_args)]
#![feature(generic_const_exprs)]
union AsBytes<T> {
  as_bytes : [u8; const {size_of::<T>()}]
}

fn main() {}

Version information

rustc 1.98.0-nightly (40557f622 2026-06-25)
binary: rustc
commit-hash: 40557f6225e337d68c8d4f086557ce54135f5dd9
commit-date: 2026-06-25
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

// We can freely ICE here as:
// - `Param` gets replaced with a placeholder during canonicalization
// - `Bound` cannot exist as we don't have a binder around the self Type
// - `Expr` is part of `feature(generic_const_exprs)` and is not implemented yet
ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) | ty::ConstKind::Expr(_) => {
panic!("unexpected const kind: {:?}", ct)
}
}
}
#[instrument(level = "trace", skip(self), ret)]
fn compute_const_arg_has_type_goal(

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed
 --> /tmp/icemaker_global_tempdir.2erhwGp5dvIV/rustc_testrunner_tmpdir_reporting.aTJzYDRohRrk/mvce.rs:3:12
  |
3 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = help: remove one of these features

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.2erhwGp5dvIV/rustc_testrunner_tmpdir_reporting.aTJzYDRohRrk/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

warning: the feature `generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.2erhwGp5dvIV/rustc_testrunner_tmpdir_reporting.aTJzYDRohRrk/mvce.rs:2:12
  |
2 | #![feature(generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #151972 <https://github.com/rust-lang/rust/issues/151972> for more information

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.2erhwGp5dvIV/rustc_testrunner_tmpdir_reporting.aTJzYDRohRrk/mvce.rs:3:12
  |
3 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

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


thread 'rustc' (77177) panicked at /rustc-dev/40557f6225e337d68c8d4f086557ce54135f5dd9/compiler/rustc_next_trait_solver/src/solve/mod.rs:231:17:
unexpected const kind: (std::mem::size_of::<!0>: FnDef(DefId(2:2648 ~ core[2ec0]::mem::size_of), [!0]))()
stack backtrace:
   0:     0x7f69750a2f49 - <<std[2a68cadfb35bda34]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[2ec008d822edb004]::fmt::Display>::fmt
   1:     0x7f697580ec08 - core[2ec008d822edb004]::fmt::write
   2:     0x7f69750b95b6 - <std[2a68cadfb35bda34]::sys::stdio::unix::Stderr as std[2a68cadfb35bda34]::io::Write>::write_fmt
   3:     0x7f69750780ae - std[2a68cadfb35bda34]::panicking::default_hook::{closure#0}
   4:     0x7f6975095ac3 - std[2a68cadfb35bda34]::panicking::default_hook
   5:     0x7f69740a6771 - std[2a68cadfb35bda34]::panicking::update_hook::<alloc[9c08d3116dc5205f]::boxed::Box<rustc_driver_impl[b066d2030f6db219]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6975095f12 - std[2a68cadfb35bda34]::panicking::panic_with_hook
   7:     0x7f6975078172 - std[2a68cadfb35bda34]::panicking::panic_handler::{closure#0}
   8:     0x7f697506c659 - std[2a68cadfb35bda34]::sys::backtrace::__rust_end_short_backtrace::<std[2a68cadfb35bda34]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f6975079bdd - __rustc[e71f75ffc133f003]::rust_begin_unwind
  10:     0x7f69720f310c - core[2ec008d822edb004]::panicking::panic_fmt
  11:     0x7f69776eba80 - <rustc_next_trait_solver[a1f2894411708918]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate, rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt>>::compute_const_evaluatable_goal.cold
  12:     0x7f69769a2de9 - <rustc_next_trait_solver[a1f2894411708918]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate> as rustc_type_ir[e826fdc123101db6]::search_graph::Delegate>::compute_goal::{closure#0}
  13:     0x7f69728f9e0d - <rustc_type_ir[e826fdc123101db6]::search_graph::SearchGraph<rustc_next_trait_solver[a1f2894411708918]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate>, rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
  14:     0x7f69763daf55 - <rustc_next_trait_solver[a1f2894411708918]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate, rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt>>::evaluate_goal_cold
  15:     0x7f69763e1dd1 - <rustc_next_trait_solver[a1f2894411708918]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate, rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt>>::evaluate_added_goals_step
  16:     0x7f69765abc83 - <rustc_next_trait_solver[a1f2894411708918]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate, rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt>>::evaluate_added_goals_and_make_canonical_response::{closure#0}
  17:     0x7f69769a07af - <rustc_next_trait_solver[a1f2894411708918]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate> as rustc_type_ir[e826fdc123101db6]::search_graph::Delegate>::compute_goal::{closure#0}
  18:     0x7f697699e8df - <rustc_type_ir[e826fdc123101db6]::search_graph::SearchGraph<rustc_next_trait_solver[a1f2894411708918]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate>, rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt>>::evaluate_goal_in_task
  19:     0x7f697699e028 - rustc_trait_selection[8c7db6004f5b8234]::solve::evaluate_root_goal_for_proof_tree_raw
  20:     0x7f697699de58 - rustc_query_impl[7ecdd8637321aee]::query_impl::evaluate_root_goal_for_proof_tree_raw::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f697699cc47 - rustc_query_impl[7ecdd8637321aee]::execution::try_execute_query::<rustc_middle[b4a081e030a285a9]::query::caches::DefaultCache<rustc_type_ir[e826fdc123101db6]::canonical::CanonicalQueryInput<rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt, rustc_type_ir[e826fdc123101db6]::solve::QueryInput<rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt, rustc_middle[b4a081e030a285a9]::ty::predicate::Predicate>>, rustc_middle[b4a081e030a285a9]::query::erase::ErasedData<[u8; 48usize]>>, false>
  22:     0x7f697699c857 - rustc_query_impl[7ecdd8637321aee]::query_impl::evaluate_root_goal_for_proof_tree_raw::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f6973305588 - <rustc_middle[b4a081e030a285a9]::ty::context::TyCtxt as rustc_type_ir[e826fdc123101db6]::interner::Interner>::evaluate_root_goal_for_proof_tree_raw
  24:     0x7f6976588dd1 - <rustc_trait_selection[8c7db6004f5b8234]::solve::delegate::SolverDelegate as rustc_next_trait_solver[a1f2894411708918]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal_for_proof_tree
  25:     0x7f6976bf4d76 - <rustc_infer[804c007b28f22ec3]::infer::InferCtxt as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::InferCtxtProofTreeExt>::visit_proof_tree_at_depth::<rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation>
  26:     0x7f6976bf603c - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  27:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  28:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  29:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  30:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  31:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  32:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  33:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  34:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  35:     0x7f6976bf5a23 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  36:     0x7f6976bf4dee - <rustc_infer[804c007b28f22ec3]::infer::InferCtxt as rustc_trait_selection[8c7db6004f5b8234]::solve::inspect::analyse::InferCtxtProofTreeExt>::visit_proof_tree_at_depth::<rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::BestObligation>
  37:     0x7f6976bf3262 - rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::derive_errors::find_best_leaf_obligation
  38:     0x7f6976bf2bab - <rustc_trait_selection[8c7db6004f5b8234]::traits::FulfillmentError as rustc_infer[804c007b28f22ec3]::traits::engine::FromSolverError<rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::NextSolverError>>::from_solver_error
  39:     0x7f69760a76f4 - <rustc_trait_selection[8c7db6004f5b8234]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[8c7db6004f5b8234]::traits::FulfillmentError> as rustc_infer[804c007b28f22ec3]::traits::engine::TraitEngine<rustc_trait_selection[8c7db6004f5b8234]::traits::FulfillmentError>>::try_evaluate_obligations
  40:     0x7f69760a3b27 - <rustc_hir_analysis[bef09c3ec5a10b3a]::check::wfcheck::WfCheckingCtxt>::deeply_normalize::<rustc_middle[b4a081e030a285a9]::ty::Ty>
  41:     0x7f69760a8736 - rustc_hir_analysis[bef09c3ec5a10b3a]::check::wfcheck::check_type_defn
  42:     0x7f69766bcfdd - rustc_hir_analysis[bef09c3ec5a10b3a]::check::check::check_item_type
  43:     0x7f69766b6226 - rustc_hir_analysis[bef09c3ec5a10b3a]::check::wfcheck::check_well_formed
  44:     0x7f69766b6207 - rustc_query_impl[7ecdd8637321aee]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  45:     0x7f69766b1371 - rustc_query_impl[7ecdd8637321aee]::execution::try_execute_query::<rustc_data_structures[642e38e42f99d6a5]::vec_cache::VecCache<rustc_span[c2b6ba5c55640e04]::def_id::LocalDefId, rustc_middle[b4a081e030a285a9]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[b4a081e030a285a9]::dep_graph::graph::DepNodeIndex>, false>
  46:     0x7f69766b1107 - rustc_query_impl[7ecdd8637321aee]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  47:     0x7f69766b2de0 - rustc_hir_analysis[bef09c3ec5a10b3a]::check::wfcheck::check_type_wf
  48:     0x7f69766b2c55 - rustc_query_impl[7ecdd8637321aee]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  49:     0x7f697690bac6 - rustc_query_impl[7ecdd8637321aee]::execution::try_execute_query::<rustc_middle[b4a081e030a285a9]::query::caches::SingleCache<rustc_middle[b4a081e030a285a9]::query::erase::ErasedData<[u8; 1usize]>>, false>
  50:     0x7f697690b8a9 - rustc_query_impl[7ecdd8637321aee]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  51:     0x7f6975beca5a - rustc_hir_analysis[bef09c3ec5a10b3a]::check_crate
  52:     0x7f6975beef74 - rustc_interface[daa44c320b53a0f8]::passes::analysis
  53:     0x7f697690c8c7 - rustc_query_impl[7ecdd8637321aee]::execution::try_execute_query::<rustc_middle[b4a081e030a285a9]::query::caches::SingleCache<rustc_middle[b4a081e030a285a9]::query::erase::ErasedData<[u8; 0usize]>>, false>
  54:     0x7f697690c5a9 - rustc_query_impl[7ecdd8637321aee]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  55:     0x7f6976955c00 - rustc_interface[daa44c320b53a0f8]::interface::run_compiler::<(), rustc_driver_impl[b066d2030f6db219]::run_compiler::{closure#0}>::{closure#1}
  56:     0x7f69769232fa - std[2a68cadfb35bda34]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[daa44c320b53a0f8]::util::run_in_thread_with_globals<rustc_interface[daa44c320b53a0f8]::util::run_in_thread_pool_with_globals<rustc_interface[daa44c320b53a0f8]::interface::run_compiler<(), rustc_driver_impl[b066d2030f6db219]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  57:     0x7f69769230ad - <std[2a68cadfb35bda34]::thread::lifecycle::spawn_unchecked<rustc_interface[daa44c320b53a0f8]::util::run_in_thread_with_globals<rustc_interface[daa44c320b53a0f8]::util::run_in_thread_pool_with_globals<rustc_interface[daa44c320b53a0f8]::interface::run_compiler<(), rustc_driver_impl[b066d2030f6db219]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2ec008d822edb004]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  58:     0x7f6976919550 - <std[2a68cadfb35bda34]::sys::thread::unix::Thread>::new::thread_start
  59:     0x7f69702981b9 - <unknown>
  60:     0x7f697031d21c - <unknown>
  61:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

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.98.0-nightly (40557f622 2026-06-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [evaluate_root_goal_for_proof_tree_raw] computing proof tree for `(ValTree(Branch([]): core::mem::size_of<^c_0>))() well-formed`
#1 [check_well_formed] checking that `AsBytes` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors; 3 warnings emitted

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

@rustbot label +F-min_generic_const_args +F-generic_const_args +F-generic_const_exprs +WG-trait-system-refactor

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_args`#![feature(generic_const_args)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions