Skip to content

[ICE]: Unevaluated ty::Const in MIR body #154747

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(generic_const_args)]
#![feature(min_generic_const_args, generic_const_items)]

type const TYPE_CONST: usize = const { 1 };

type const FREE2<const I: usize>: usize = const { I + 1 };

fn main() {}

original:

#![expect(incomplete_features)]
#![feature(min_generic_const_args, generic_const_items)]


type const TYPE_CONST: usize = const { 1 };
//~^ ERROR generic parameters may not be used in const operations

type const FREE2<const I: usize>: usize = const { I + 1 };
//~^ ERROR generic parameters may not be used in const operations

fn main() {}

Version information

rustc 1.96.0-nightly (5bbdeaa9a 2026-04-03)
binary: rustc
commit-hash: 5bbdeaa9a8dc563185f40e99f96704cbcc7a6e6e
commit-date: 2026-04-03
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally -Zcrate-attr=feature(generic_const_args)

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.PFB0IC9ewvli/rustc_testrunner_tmpdir_reporting.Qvz3cCacfzVR/mvce.rs:1:12
  |
1 | #![feature(min_generic_const_args, generic_const_items)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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_items` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.PFB0IC9ewvli/rustc_testrunner_tmpdir_reporting.Qvz3cCacfzVR/mvce.rs:1:36
  |
1 | #![feature(min_generic_const_args, generic_const_items)]
  |                                    ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information

warning: constant `TYPE_CONST` is never used
 --> /tmp/icemaker_global_tempdir.PFB0IC9ewvli/rustc_testrunner_tmpdir_reporting.Qvz3cCacfzVR/mvce.rs:3:12
  |
3 | type const TYPE_CONST: usize = const { 1 };
  |            ^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: constant `FREE2` is never used
 --> /tmp/icemaker_global_tempdir.PFB0IC9ewvli/rustc_testrunner_tmpdir_reporting.Qvz3cCacfzVR/mvce.rs:5:12
  |
5 | type const FREE2<const I: usize>: usize = const { I + 1 };
  |            ^^^^^

warning: 4 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: Unevaluated `ty::Const` in MIR body
  |
  = note: delayed at /rustc-dev/5bbdeaa9a8dc563185f40e99f96704cbcc7a6e6e/compiler/rustc_middle/src/mir/consts.rs:330:35
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<&str>
             4: <rustc_middle::mir::consts::Const>::eval
             5: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::push_stack_frame_raw
             6: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
             7: rustc_query_impl::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
             8: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::ErasedData<[u8; 24]>>, false>
             9: rustc_query_impl::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
            10: rustc_const_eval::const_eval::valtrees::eval_to_valtree
            11: <rustc_const_eval::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
            12: rustc_query_impl::query_impl::eval_to_valtree::invoke_provider_fn::__rust_begin_short_backtrace
            13: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::ErasedData<[u8; 16]>>, false>
            14: rustc_query_impl::query_impl::eval_to_valtree::execute_query_non_incr::__rust_end_short_backtrace
            15: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
            16: rustc_trait_selection::traits::try_evaluate_const
            17: <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::delegate::SolverDelegate>::evaluate_const
            18: <rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate> as rustc_type_ir::search_graph::Delegate>::compute_goal::{closure#0}
            19: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal::{closure#0}::{closure#2}
            20: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
            21: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::try_evaluate_added_goals
            22: <rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate> as rustc_type_ir::search_graph::Delegate>::compute_goal::{closure#0}
            23: <rustc_type_ir::search_graph::SearchGraph<rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<rustc_trait_selection::solve::delegate::SolverDelegate>, rustc_middle::ty::context::TyCtxt>>::evaluate_goal::{closure#0}::{closure#2}
            24: <rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<rustc_trait_selection::solve::delegate::SolverDelegate, rustc_middle::ty::context::TyCtxt>>::evaluate_goal_raw
            25: <rustc_trait_selection::solve::delegate::SolverDelegate as rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
            26: <rustc_trait_selection::solve::fulfill::FulfillmentCtxt<rustc_trait_selection::traits::FulfillmentError> as rustc_infer::traits::engine::TraitEngine<rustc_trait_selection::traits::FulfillmentError>>::try_evaluate_obligations
            27: <rustc_trait_selection::solve::normalize::NormalizationFolder<rustc_trait_selection::traits::FulfillmentError>>::normalize_alias_term
            28: <rustc_trait_selection::solve::normalize::NormalizationFolder<rustc_trait_selection::traits::FulfillmentError> as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_const::{closure#0}
            29: rustc_hir_analysis::check::wfcheck::check_type_const
            30: rustc_hir_analysis::check::check::check_item_type
            31: rustc_hir_analysis::check::wfcheck::check_well_formed
            32: rustc_query_impl::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
            33: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 1]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
            34: rustc_query_impl::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
            35: rustc_hir_analysis::check::wfcheck::check_type_wf
            36: rustc_query_impl::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
            37: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 1]>>, false>
            38: rustc_query_impl::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
            39: rustc_hir_analysis::check_crate
            40: rustc_interface::passes::analysis
            41: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
            42: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
            43: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            44: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            45: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            46: <std::sys::thread::unix::Thread>::new::thread_start
            47: <unknown>
            48: <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 (5bbdeaa9a 2026-04-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z crate-attr=feature(generic_const_args) -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@rustbot label +F-min_generic_const_args +F-generic_const_items +F-generic_const_args +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_items`#![feature(generic_const_items)]`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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions