Skip to content

ICE: broken mir: bad assignment #143204

Open
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![feature(loop_match)]
fn main() {
    let state = 0;
    #[loop_match]
    'a: loop {
        state = 'blk: {
            match state {
                0 => 1,
            }
        }
    }
}

Version information

rustc 1.90.0-nightly (5e749eb66 2025-06-29)
binary: rustc
commit-hash: 5e749eb66f93ee998145399fbdde337e57cd72ef
commit-date: 2025-06-29
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

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

Program output

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

warning: unused label
 --> /tmp/icemaker_global_tempdir.jkNKqdzS3dza/rustc_testrunner_tmpdir_reporting.uY8eIKBuH6aU/mvce.rs:5:5
  |
5 |     'a: loop {
  |     ^^
  |
  = note: `#[warn(unused_labels)]` on by default

warning: unused label
 --> /tmp/icemaker_global_tempdir.jkNKqdzS3dza/rustc_testrunner_tmpdir_reporting.uY8eIKBuH6aU/mvce.rs:6:17
  |
6 |         state = 'blk: {
  |                 ^^^^

warning: 3 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: broken MIR in DefId(0:3 ~ mvce[e0ba]::main) (_2 = const 1_i32): bad assignment (! = i32): NoSolution
 --> /tmp/icemaker_global_tempdir.jkNKqdzS3dza/rustc_testrunner_tmpdir_reporting.uY8eIKBuH6aU/mvce.rs:8:22
  |
8 |                 0 => 1,
  |                      ^
  |
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:657:21
         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>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
         5: rustc_borrowck::type_check::type_check
         6: rustc_borrowck::do_mir_borrowck
         7: rustc_borrowck::mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        11: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
        12: rustc_interface::passes::analysis
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: 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}, ()>
        19: <<std::thread::Builder>::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}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: <unknown>
        22: <unknown>
 --> /tmp/icemaker_global_tempdir.jkNKqdzS3dza/rustc_testrunner_tmpdir_reporting.uY8eIKBuH6aU/mvce.rs:8:22
  |
8 |                 0 => 1,
  |                      ^

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.90.0-nightly (5e749eb66 2025-06-29) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label +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 loopI-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