Skip to content

[ICE]: UnevaluatedConst #156410

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait T {
    type const N: usize;
    fn a() {
        let mut state;
        #[loop_match]
        loop {
            state = 'blk: {
                match state {
                    0 =>
                    {
                        #[const_continue]
                        break 'blk Self::N
                    }
                    _ => todo!(),
                }
            }
        }
    }
}

original:

#![feature(min_generic_const_args)]
#![feature(loop_match)]

trait T {
    type const N: usize;
    fn a() {
        let mut state;
        #[loop_match]
        loop {
            state = 'blk: {
                match state {
                    0 =>
                    {
                        #[const_continue]
                        break 'blk Self::N
                    }
                    _ => todo!(),
                }
            }
        }
    }
}

fn main() {}

Version information

rustc 1.97.0-nightly (99eed207b 2026-05-10)
binary: rustc
commit-hash: 99eed207b47aca1fec5c665531db8e948a92d0ca
commit-date: 2026-05-10
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Possibly related line of code:

let (uv, ty) = match constant.const_ {
mir::Const::Unevaluated(uv, ty) => (uv.shrink(), ty),
mir::Const::Ty(_, c) => match c.kind() {
// A constant that came from a const generic but was then used as an argument to
// old-style simd_shuffle (passing as argument instead of as a generic param).
ty::ConstKind::Value(cv) => return Ok((cv.valtree, cv.ty)),
other => span_bug!(constant.span, "{other:#?}"),
},
mir::Const::Val(mir::ConstValue::Scalar(mir::interpret::Scalar::Int(val)), ty) => {
return Ok((ValTree::from_scalar_int(self.tcx, val), ty));
}
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
// a constant and write that value back into `Operand`s. This could happen, but is

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0658]: `type const` syntax is experimental
 --> /tmp/icemaker_global_tempdir.cbtpHDJhLmK7/rustc_testrunner_tmpdir_reporting.DiN3YUxY4h5m/mvce.rs:2:5
  |
2 |     type const N: usize;
  |     ^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
  = note: this compiler was built on 2026-05-10; consider upgrading it if it is out of date

error[E0658]: associated `type const` are unstable
 --> /tmp/icemaker_global_tempdir.cbtpHDJhLmK7/rustc_testrunner_tmpdir_reporting.DiN3YUxY4h5m/mvce.rs:2:5
  |
2 |     type const N: usize;
  |     ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
  = note: this compiler was built on 2026-05-10; consider upgrading it if it is out of date

error[E0658]: the `#[loop_match]` attribute is an experimental feature
 --> /tmp/icemaker_global_tempdir.cbtpHDJhLmK7/rustc_testrunner_tmpdir_reporting.DiN3YUxY4h5m/mvce.rs:5:9
  |
5 |         #[loop_match]
  |         ^^^^^^^^^^^^^
  |
  = note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information
  = help: add `#![feature(loop_match)]` to the crate attributes to enable
  = note: this compiler was built on 2026-05-10; consider upgrading it if it is out of date

error[E0658]: the `#[const_continue]` attribute is an experimental feature
  --> /tmp/icemaker_global_tempdir.cbtpHDJhLmK7/rustc_testrunner_tmpdir_reporting.DiN3YUxY4h5m/mvce.rs:11:25
   |
11 |                         #[const_continue]
   |                         ^^^^^^^^^^^^^^^^^
   |
   = note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information
   = help: add `#![feature(loop_match)]` to the crate attributes to enable
   = note: this compiler was built on 2026-05-10; consider upgrading it if it is out of date

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

error: internal compiler error: /rustc-dev/99eed207b47aca1fec5c665531db8e948a92d0ca/compiler/rustc_mir_build/src/builder/scope.rs:854:26: UnevaluatedConst { def: DefId(0:4 ~ mvce[dcec]::T::N), args: [Self/#0] }
  --> /tmp/icemaker_global_tempdir.cbtpHDJhLmK7/rustc_testrunner_tmpdir_reporting.DiN3YUxY4h5m/mvce.rs:12:36
   |
12 |                         break 'blk Self::N
   |                                    ^^^^^^^


thread 'rustc' (3110715) panicked at /rustc-dev/99eed207b47aca1fec5c665531db8e948a92d0ca/compiler/rustc_mir_build/src/builder/scope.rs:854:26:
Box<dyn Any>
stack backtrace:
   0:     0x7f5d09491db9 - <<std[a63f9b705296e80a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c8275d783776ad3c]::fmt::Display>::fmt
   1:     0x7f5d09c1b888 - core[c8275d783776ad3c]::fmt::write
   2:     0x7f5d094a89d6 - <std[a63f9b705296e80a]::sys::stdio::unix::Stderr as std[a63f9b705296e80a]::io::Write>::write_fmt
   3:     0x7f5d09467dfe - std[a63f9b705296e80a]::panicking::default_hook::{closure#0}
   4:     0x7f5d09485473 - std[a63f9b705296e80a]::panicking::default_hook
   5:     0x7f5d08367631 - std[a63f9b705296e80a]::panicking::update_hook::<alloc[8808748864ecd057]::boxed::Box<rustc_driver_impl[3a67401c370443cb]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f5d09485752 - std[a63f9b705296e80a]::panicking::panic_with_hook
   7:     0x7f5d08395081 - std[a63f9b705296e80a]::panicking::begin_panic::<rustc_errors[a20c05da5b198337]::ExplicitBug>::{closure#0}
   8:     0x7f5d0838e076 - std[a63f9b705296e80a]::sys::backtrace::__rust_end_short_backtrace::<std[a63f9b705296e80a]::panicking::begin_panic<rustc_errors[a20c05da5b198337]::ExplicitBug>::{closure#0}, !>
   9:     0x7f5d0838bd88 - std[a63f9b705296e80a]::panicking::begin_panic::<rustc_errors[a20c05da5b198337]::ExplicitBug>
  10:     0x7f5d083a0561 - <rustc_errors[a20c05da5b198337]::diagnostic::BugAbort as rustc_errors[a20c05da5b198337]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f5d0898953c - <rustc_errors[a20c05da5b198337]::DiagCtxtHandle>::span_bug::<rustc_span[b61981f7e08eaecb]::span_encoding::Span, alloc[8808748864ecd057]::string::String>
  12:     0x7f5d089b4b66 - rustc_middle[ed9d20c5becdf50d]::util::bug::opt_span_bug_fmt::<rustc_span[b61981f7e08eaecb]::span_encoding::Span>::{closure#0}
  13:     0x7f5d089b4cf2 - rustc_middle[ed9d20c5becdf50d]::ty::context::tls::with_opt::<rustc_middle[ed9d20c5becdf50d]::util::bug::opt_span_bug_fmt<rustc_span[b61981f7e08eaecb]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f5d089a395b - rustc_middle[ed9d20c5becdf50d]::ty::context::tls::with_context_opt::<rustc_middle[ed9d20c5becdf50d]::ty::context::tls::with_opt<rustc_middle[ed9d20c5becdf50d]::util::bug::opt_span_bug_fmt<rustc_span[b61981f7e08eaecb]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f5d0613dfc8 - rustc_middle[ed9d20c5becdf50d]::util::bug::span_bug_fmt::<rustc_span[b61981f7e08eaecb]::span_encoding::Span>
  16:     0x7f5d09f3b7e4 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::stmt_expr
  17:     0x7f5d0a9662a9 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  18:     0x7f5d09c18a45 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::as_temp::{closure#0}
  19:     0x7f5d0a9658a1 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  20:     0x7f5d0a96323e - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  21:     0x7f5d0aafc2bb - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::ast_block_stmts
  22:     0x7f5d0aafa40f - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::ast_block
  23:     0x7f5d0a9641b1 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  24:     0x7f5d0a96323e - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  25:     0x7f5d0a95c355 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::lower_match_arms
  26:     0x7f5d08a541ea - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::in_breakable_scope::<<rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest::{closure#4}>
  27:     0x7f5d0a96befe - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  28:     0x7f5d09c18a45 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::as_temp::{closure#0}
  29:     0x7f5d0a9658a1 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  30:     0x7f5d0a96323e - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  31:     0x7f5d0aafc2bb - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::ast_block_stmts
  32:     0x7f5d0aafa40f - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::ast_block
  33:     0x7f5d0a9641b1 - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  34:     0x7f5d0a96323e - <rustc_mir_build[2dea8492cf446959]::builder::Builder>::expr_into_dest
  35:     0x7f5d09f2a919 - rustc_mir_build[2dea8492cf446959]::builder::build_mir_inner_impl
  36:     0x7f5d09c0e274 - rustc_mir_transform[928932c6793842ef]::mir_built
  37:     0x7f5d09f17e66 - rustc_query_impl[a5a958d8a0a2d143]::execution::try_execute_query::<rustc_data_structures[c827ebdc85a422ac]::vec_cache::VecCache<rustc_span[b61981f7e08eaecb]::def_id::LocalDefId, rustc_middle[ed9d20c5becdf50d]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[ed9d20c5becdf50d]::dep_graph::graph::DepNodeIndex>, false>
  38:     0x7f5d09f17983 - rustc_query_impl[a5a958d8a0a2d143]::query_impl::mir_built::execute_query_non_incr::__rust_end_short_backtrace
  39:     0x7f5d065df2f4 - rustc_mir_build[2dea8492cf446959]::check_unsafety::check_unsafety
  40:     0x7f5d09f1b752 - rustc_query_impl[a5a958d8a0a2d143]::execution::try_execute_query::<rustc_data_structures[c827ebdc85a422ac]::vec_cache::VecCache<rustc_span[b61981f7e08eaecb]::def_id::LocalDefId, rustc_middle[ed9d20c5becdf50d]::query::erase::ErasedData<[u8; 0usize]>, rustc_middle[ed9d20c5becdf50d]::dep_graph::graph::DepNodeIndex>, false>
  41:     0x7f5d09f1b452 - rustc_query_impl[a5a958d8a0a2d143]::query_impl::check_unsafety::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7f5d09f1a6aa - <rustc_middle[ed9d20c5becdf50d]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[20fa5253bc5acf69]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  43:     0x7f5d09f19a36 - rustc_interface[20fa5253bc5acf69]::passes::analysis
  44:     0x7f5d0acfcf89 - rustc_query_impl[a5a958d8a0a2d143]::execution::try_execute_query::<rustc_middle[ed9d20c5becdf50d]::query::caches::SingleCache<rustc_middle[ed9d20c5becdf50d]::query::erase::ErasedData<[u8; 0usize]>>, false>
  45:     0x7f5d0acfcc69 - rustc_query_impl[a5a958d8a0a2d143]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  46:     0x7f5d0ad1c25b - rustc_interface[20fa5253bc5acf69]::interface::run_compiler::<(), rustc_driver_impl[3a67401c370443cb]::run_compiler::{closure#0}>::{closure#1}
  47:     0x7f5d0ace9a3a - std[a63f9b705296e80a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[20fa5253bc5acf69]::util::run_in_thread_with_globals<rustc_interface[20fa5253bc5acf69]::util::run_in_thread_pool_with_globals<rustc_interface[20fa5253bc5acf69]::interface::run_compiler<(), rustc_driver_impl[3a67401c370443cb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  48:     0x7f5d0acea12d - <std[a63f9b705296e80a]::thread::lifecycle::spawn_unchecked<rustc_interface[20fa5253bc5acf69]::util::run_in_thread_with_globals<rustc_interface[20fa5253bc5acf69]::util::run_in_thread_pool_with_globals<rustc_interface[20fa5253bc5acf69]::interface::run_compiler<(), rustc_driver_impl[3a67401c370443cb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c8275d783776ad3c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f5d0aceaf2c - <std[a63f9b705296e80a]::sys::thread::unix::Thread>::new::thread_start
  50:     0x7f5d0449697a - <unknown>
  51:     0x7f5d0451a2bc - <unknown>
  52:                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 (99eed207b 2026-05-10) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_built] building MIR for `T::a`
#1 [check_unsafety] unsafety-checking `T::a`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 6 previous errors

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@rustbot label +F-min_generic_const_args +F-loop_match

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-loop_matchwhen you match up with someone and they really throw you for a loopF-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

    Fields

    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