rust-lang / rust-lang/rust

[ICE]: UnevaluatedConst

Open
#156,410 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-loop_match F-min_generic_const_args I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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:
https://github.com/rust-lang/rust/blob/99eed207b47aca1fec5c665531db8e948a92d0ca/compiler/rustc_mir_build/src/builder/scope.rs#L848-L860

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced reproducer in a.rs and the linked compiler/rustc_mir_build/src/builder/scope.rs lines 848-860. Run it with the listed nightly compiler and feature gates, then trace the MIR-building path shown in the backtrace around stmt_expr and expr_into_dest. Done means the reproducer no longer triggers an internal compiler error and has suitable regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.