Skip to content

ICE: by_move_body: impossible case reached #129676

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

async fn fun<'a>() {
    let _ = join_all((0..3).map(async |_| {})).await;
}

original:

#![feature(async_closure)]

use futures::future::join_all;

async fn fun<'a>(param: &'a u32) {
	let _ = join_all((0..3).map(async |_| {
		format!("{}", param)
	})).await;
}

fn main() {
	futures::executor::block_on(fun(&1));
}

Version information

rustc 1.82.0-nightly (d9a2cc4da 2024-08-27)
binary: rustc
commit-hash: d9a2cc4daee38c63b2f69710ed61d40acc32b709
commit-date: 2024-08-27
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options --edition=2024

Program output

error[E0658]: async closures are unstable
 --> /tmp/icemaker_global_tempdir.qQOR5PdPVeKt/rustc_testrunner_tmpdir_reporting.ZhY387l6Z9MY/mvce.rs:2:33
  |
2 |     let _ = join_all((0..3).map(async |_| {})).await;
  |                                 ^^^^^
  |
  = note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
  = help: add `#![feature(async_closure)]` to the crate attributes to enable
  = note: this compiler was built on 2024-08-27; consider upgrading it if it is out of date
  = help: to use an async block, remove the `||`: `async {`

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

error[E0425]: cannot find function `join_all` in this scope
 --> /tmp/icemaker_global_tempdir.qQOR5PdPVeKt/rustc_testrunner_tmpdir_reporting.ZhY387l6Z9MY/mvce.rs:2:13
  |
2 |     let _ = join_all((0..3).map(async |_| {})).await;
  |             ^^^^^^^^ not found in this scope

error: internal compiler error: compiler/rustc_mir_transform/src/coroutine/by_move_body.rs:110:9: impossible case reached

thread 'rustc' panicked at compiler/rustc_mir_transform/src/coroutine/by_move_body.rs:110:9:
Box<dyn Any>
stack backtrace:
   0:     0x796ab79ed14d - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h7363ce71779ec9c6
   1:     0x796ab8202c97 - core::fmt::write::h44e970cb9b26547f
   2:     0x796ab91cd111 - std::io::Write::write_fmt::h83cfd3c735df90d5
   3:     0x796ab79ef82b - std::panicking::default_hook::{{closure}}::h6f491270a33b28e9
   4:     0x796ab79ef49e - std::panicking::default_hook::h4093e14fa2c2927b
   5:     0x796ab6b502b9 - std[c988b194526ad436]::panicking::update_hook::<alloc[fb4a6b32a2001a3d]::boxed::Box<rustc_driver_impl[2a2e732cd68cd602]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x796ab79f0147 - std::panicking::rust_panic_with_hook::h076b5468ef3279ca
   7:     0x796ab6b89dc1 - std[c988b194526ad436]::panicking::begin_panic::<rustc_errors[c6d202a4b3371a7f]::ExplicitBug>::{closure#0}
   8:     0x796ab6b7d486 - std[c988b194526ad436]::sys::backtrace::__rust_end_short_backtrace::<std[c988b194526ad436]::panicking::begin_panic<rustc_errors[c6d202a4b3371a7f]::ExplicitBug>::{closure#0}, !>
   9:     0x796ab6b7d206 - std[c988b194526ad436]::panicking::begin_panic::<rustc_errors[c6d202a4b3371a7f]::ExplicitBug>
  10:     0x796ab6b92fe1 - <rustc_errors[c6d202a4b3371a7f]::diagnostic::BugAbort as rustc_errors[c6d202a4b3371a7f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x796ab715ad94 - rustc_middle[953b8dd86f89e09]::util::bug::opt_span_bug_fmt::<rustc_span[acd227fd1c8987f]::span_encoding::Span>::{closure#0}
  12:     0x796ab714094a - rustc_middle[953b8dd86f89e09]::ty::context::tls::with_opt::<rustc_middle[953b8dd86f89e09]::util::bug::opt_span_bug_fmt<rustc_span[acd227fd1c8987f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x796ab71407fb - rustc_middle[953b8dd86f89e09]::ty::context::tls::with_context_opt::<rustc_middle[953b8dd86f89e09]::ty::context::tls::with_opt<rustc_middle[953b8dd86f89e09]::util::bug::opt_span_bug_fmt<rustc_span[acd227fd1c8987f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x796ab4c1ade0 - rustc_middle[953b8dd86f89e09]::util::bug::bug_fmt
  15:     0x796ab72d008b - rustc_mir_transform[f8a23681d5b0e319]::coroutine::by_move_body::coroutine_by_move_body_def_id
  16:     0x796ab752a8bc - rustc_query_impl[a5edc71043c388ee]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5edc71043c388ee]::query_impl::coroutine_by_move_body_def_id::dynamic_query::{closure#2}::{closure#0}, rustc_middle[953b8dd86f89e09]::query::erase::Erased<[u8; 8usize]>>
  17:     0x796ab822a66e - rustc_query_system[aca73356a4d1940b]::query::plumbing::try_execute_query::<rustc_query_impl[a5edc71043c388ee]::DynamicConfig<rustc_query_system[aca73356a4d1940b]::query::caches::DefIdCache<rustc_middle[953b8dd86f89e09]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a5edc71043c388ee]::plumbing::QueryCtxt, false>
  18:     0x796ab753861e - rustc_query_impl[a5edc71043c388ee]::query_impl::coroutine_by_move_body_def_id::get_query_non_incr::__rust_end_short_backtrace
  19:     0x796ab88d6817 - rustc_interface[acf51b738136240b]::passes::run_required_analyses
  20:     0x796ab8fe879e - rustc_interface[acf51b738136240b]::passes::analysis
  21:     0x796ab8fe8771 - rustc_query_impl[a5edc71043c388ee]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5edc71043c388ee]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[953b8dd86f89e09]::query::erase::Erased<[u8; 1usize]>>
  22:     0x796ab91702ae - rustc_query_system[aca73356a4d1940b]::query::plumbing::try_execute_query::<rustc_query_impl[a5edc71043c388ee]::DynamicConfig<rustc_query_system[aca73356a4d1940b]::query::caches::SingleCache<rustc_middle[953b8dd86f89e09]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a5edc71043c388ee]::plumbing::QueryCtxt, false>
  23:     0x796ab917000f - rustc_query_impl[a5edc71043c388ee]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  24:     0x796ab8fd6eec - rustc_interface[acf51b738136240b]::interface::run_compiler::<core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>, rustc_driver_impl[2a2e732cd68cd602]::run_compiler::{closure#0}>::{closure#1}
  25:     0x796ab907ca50 - std[c988b194526ad436]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[acf51b738136240b]::util::run_in_thread_with_globals<rustc_interface[acf51b738136240b]::util::run_in_thread_pool_with_globals<rustc_interface[acf51b738136240b]::interface::run_compiler<core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>, rustc_driver_impl[2a2e732cd68cd602]::run_compiler::{closure#0}>::{closure#1}, core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>>::{closure#0}, core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>>
  26:     0x796ab907d0ba - <<std[c988b194526ad436]::thread::Builder>::spawn_unchecked_<rustc_interface[acf51b738136240b]::util::run_in_thread_with_globals<rustc_interface[acf51b738136240b]::util::run_in_thread_pool_with_globals<rustc_interface[acf51b738136240b]::interface::run_compiler<core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>, rustc_driver_impl[2a2e732cd68cd602]::run_compiler::{closure#0}>::{closure#1}, core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>>::{closure#0}, core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1ab42d1e62fda574]::result::Result<(), rustc_span[acd227fd1c8987f]::ErrorGuaranteed>>::{closure#1} as core[1ab42d1e62fda574]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x796ab907d42b - std::sys::pal::unix::thread::Thread::new::thread_start::h5546d7ef64313a46
  28:     0x796aba6e039d - <unknown>
  29:     0x796aba76549c - <unknown>
  30:                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.82.0-nightly (d9a2cc4da 2024-08-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options -Z dump-mir-dir=dir

query stack during panic:
#0 [coroutine_by_move_body_def_id] looking up the coroutine by-move body for `fun::{closure#0}::{closure#0}::{closure#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

@rustbot label +F-async_closure

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-closures`async || {}`C-bugCategory: This is a bug.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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions