Skip to content

ice: coroutine: impossible case reached #120791

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn main() {
    let _ = #[track_caller]
    async || {
        used_fn();

        0
    };
}
original code

original:

// edition:2021
// revisions: afn nofeat

#![feature(async_closure, stmt_expr_attributes)]
#![cfg_attr(afn, feature(async_fn_track_caller))]

fn main() {
    let _ = #[track_caller] async || {
    used_fn();
    let foo = Foo;
    foo.bar2();
    0
};
}

#[track_caller]
async fn foo() {
    let _ = #[track_caller] async || {
        //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
    };
}

async fn foo2() {
    let _ = #[track_caller] || {
        //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
    };
}

fn foo3() {
    async {
        //~^ ERROR mismatched types
        let _ = #[track_caller] || {
            //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
        };
    }
}

async fn foo4() {
    let _ = || {
        #[track_caller] || {
            //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
        };
    };
}

fn foo5() {
    async {
        //~^ ERROR mismatched types
        let _ = || {
            #[track_caller] || {
                //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
            };
        };
    }
}

Version information

rustc 1.78.0-nightly (af88f7db5 2024-02-08)
binary: rustc
commit-hash: af88f7db51f6f2a1472f9279d7c7e7c822afff77
commit-date: 2024-02-08
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

error[E0658]: attributes on expressions are experimental
 --> /tmp/icemaker_global_tempdir.8ddDeDsz6Fon/rustc_testrunner_tmpdir_reporting.0YEdWdPSXD63/mvce.rs:2:13
  |
2 |     let _ = #[track_caller]
  |             ^^^^^^^^^^^^^^^
  |
  = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
  = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-08; consider upgrading it if it is out of date

error[E0658]: async closures are unstable
 --> /tmp/icemaker_global_tempdir.8ddDeDsz6Fon/rustc_testrunner_tmpdir_reporting.0YEdWdPSXD63/mvce.rs:3:5
  |
3 |     async || {
  |     ^^^^^
  |
  = 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-02-08; consider upgrading it if it is out of date
  = help: to use an async block, remove the `||`: `async {`

error[E0658]: `#[track_caller]` on closures is currently unstable
 --> /tmp/icemaker_global_tempdir.8ddDeDsz6Fon/rustc_testrunner_tmpdir_reporting.0YEdWdPSXD63/mvce.rs:2:13
  |
2 |     let _ = #[track_caller]
  |             ^^^^^^^^^^^^^^^
  |
  = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
  = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-08; consider upgrading it if it is out of date

error[E0425]: cannot find function `used_fn` in this scope
 --> /tmp/icemaker_global_tempdir.8ddDeDsz6Fon/rustc_testrunner_tmpdir_reporting.0YEdWdPSXD63/mvce.rs:4:9
  |
4 |         used_fn();
  |         ^^^^^^^ not found in this scope

error: internal compiler error: compiler/rustc_mir_transform/src/coroutine/by_move_body.rs:26:66: impossible case reached

thread 'rustc' panicked at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/compiler/rustc_errors/src/lib.rs:922:30:
Box<dyn Any>
stack backtrace:
   0:     0x7ff511255dd6 - std::backtrace_rs::backtrace::libunwind::trace::hf92ca961e56825b0
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7ff511255dd6 - std::backtrace_rs::backtrace::trace_unsynchronized::h23f341cc1a6c507f
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff511255dd6 - std::sys_common::backtrace::_print_fmt::ha5a5ba44893edc7f
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ff511255dd6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h667e6ba5a1d3724e
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff5112a8830 - core::fmt::rt::Argument::fmt::h06c91f49bef095fb
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/core/src/fmt/rt.rs:142:9
   5:     0x7ff5112a8830 - core::fmt::write::h8e4b31b0aa81d13f
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/core/src/fmt/mod.rs:1120:17
   6:     0x7ff51124964f - std::io::Write::write_fmt::h4c479f5c53dfe78c
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/io/mod.rs:1854:15
   7:     0x7ff511255bb4 - std::sys_common::backtrace::_print::he414f5864df55ed1
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff511255bb4 - std::sys_common::backtrace::print::h939e58bdcc61d57d
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff511258947 - std::panicking::default_hook::{{closure}}::h244e48e05cd664b2
  10:     0x7ff5112586a9 - std::panicking::default_hook::hf842080c39497dac
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/panicking.rs:292:9
  11:     0x7ff50df454ac - std[f801e042bca9681]::panicking::update_hook::<alloc[1377227f5558ef79]::boxed::Box<rustc_driver_impl[65af58b05c4f91ef]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ff511259096 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hee9c09a26ce84f59
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/alloc/src/boxed.rs:2029:9
  13:     0x7ff511259096 - std::panicking::rust_panic_with_hook::h83c20f9191a2a712
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/panicking.rs:785:13
  14:     0x7ff50df76f04 - std[f801e042bca9681]::panicking::begin_panic::<rustc_errors[89ec94d63507ad05]::ExplicitBug>::{closure#0}
  15:     0x7ff50df735f6 - std[f801e042bca9681]::sys_common::backtrace::__rust_end_short_backtrace::<std[f801e042bca9681]::panicking::begin_panic<rustc_errors[89ec94d63507ad05]::ExplicitBug>::{closure#0}, !>
  16:     0x7ff50df6ea66 - std[f801e042bca9681]::panicking::begin_panic::<rustc_errors[89ec94d63507ad05]::ExplicitBug>
  17:     0x7ff50df82b61 - <rustc_errors[89ec94d63507ad05]::diagnostic_builder::BugAbort as rustc_errors[89ec94d63507ad05]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7ff50e3369be - <rustc_errors[89ec94d63507ad05]::DiagCtxt>::bug::<alloc[1377227f5558ef79]::string::String>
  19:     0x7ff50e3d23db - rustc_middle[2cc1c6e52ad3d43f]::util::bug::opt_span_bug_fmt::<rustc_span[467c297c964200f6]::span_encoding::Span>::{closure#0}
  20:     0x7ff50e3b990a - rustc_middle[2cc1c6e52ad3d43f]::ty::context::tls::with_opt::<rustc_middle[2cc1c6e52ad3d43f]::util::bug::opt_span_bug_fmt<rustc_span[467c297c964200f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7ff50e3b9788 - rustc_middle[2cc1c6e52ad3d43f]::ty::context::tls::with_context_opt::<rustc_middle[2cc1c6e52ad3d43f]::ty::context::tls::with_opt<rustc_middle[2cc1c6e52ad3d43f]::util::bug::opt_span_bug_fmt<rustc_span[467c297c964200f6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7ff50c367db0 - rustc_middle[2cc1c6e52ad3d43f]::util::bug::bug_fmt
  23:     0x7ff50f2103d8 - <rustc_mir_transform[f04df7d082cb6ded]::coroutine::by_move_body::ByMoveBody as rustc_middle[2cc1c6e52ad3d43f]::mir::MirPass>::run_pass
  24:     0x7ff50f2123e6 - rustc_mir_transform[f04df7d082cb6ded]::pass_manager::run_passes_inner
  25:     0x7ff50f5e1ee0 - rustc_mir_transform[f04df7d082cb6ded]::mir_const
  26:     0x7ff50f5e1c69 - rustc_query_impl[5ca841c3c79670ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7ff50f3e38fa - rustc_query_system[125a8aa150dcabe3]::query::plumbing::try_execute_query::<rustc_query_impl[5ca841c3c79670ea]::DynamicConfig<rustc_query_system[125a8aa150dcabe3]::query::caches::VecCache<rustc_span[467c297c964200f6]::def_id::LocalDefId, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5ca841c3c79670ea]::plumbing::QueryCtxt, false>
  28:     0x7ff50f3e3350 - rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7ff50d453e02 - rustc_mir_transform[f04df7d082cb6ded]::mir_promoted
  30:     0x7ff50f8cc392 - rustc_query_impl[5ca841c3c79670ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 16usize]>>
  31:     0x7ff50f8cc65c - rustc_query_system[125a8aa150dcabe3]::query::plumbing::try_execute_query::<rustc_query_impl[5ca841c3c79670ea]::DynamicConfig<rustc_query_system[125a8aa150dcabe3]::query::caches::VecCache<rustc_span[467c297c964200f6]::def_id::LocalDefId, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[5ca841c3c79670ea]::plumbing::QueryCtxt, false>
  32:     0x7ff50ffdaf13 - rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7ff50ffdb02e - rustc_borrowck[736b5a37e6245cb0]::mir_borrowck
  34:     0x7ff50ffdaf59 - rustc_query_impl[5ca841c3c79670ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7ff50f3e38fa - rustc_query_system[125a8aa150dcabe3]::query::plumbing::try_execute_query::<rustc_query_impl[5ca841c3c79670ea]::DynamicConfig<rustc_query_system[125a8aa150dcabe3]::query::caches::VecCache<rustc_span[467c297c964200f6]::def_id::LocalDefId, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5ca841c3c79670ea]::plumbing::QueryCtxt, false>
  36:     0x7ff50f3e3290 - rustc_query_impl[5ca841c3c79670ea]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7ff50fbd40e7 - rustc_interface[c2746bee48761670]::passes::analysis
  38:     0x7ff50fbd3bdf - rustc_query_impl[5ca841c3c79670ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ca841c3c79670ea]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 1usize]>>
  39:     0x7ff50fea17b2 - rustc_query_system[125a8aa150dcabe3]::query::plumbing::try_execute_query::<rustc_query_impl[5ca841c3c79670ea]::DynamicConfig<rustc_query_system[125a8aa150dcabe3]::query::caches::SingleCache<rustc_middle[2cc1c6e52ad3d43f]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5ca841c3c79670ea]::plumbing::QueryCtxt, false>
  40:     0x7ff50fea1515 - rustc_query_impl[5ca841c3c79670ea]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7ff50fee2436 - rustc_interface[c2746bee48761670]::interface::run_compiler::<core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>, rustc_driver_impl[65af58b05c4f91ef]::run_compiler::{closure#0}>::{closure#0}
  42:     0x7ff50fb60248 - std[f801e042bca9681]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c2746bee48761670]::util::run_in_thread_with_globals<rustc_interface[c2746bee48761670]::util::run_in_thread_pool_with_globals<rustc_interface[c2746bee48761670]::interface::run_compiler<core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>, rustc_driver_impl[65af58b05c4f91ef]::run_compiler::{closure#0}>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>
  43:     0x7ff50fb60077 - <<std[f801e042bca9681]::thread::Builder>::spawn_unchecked_<rustc_interface[c2746bee48761670]::util::run_in_thread_with_globals<rustc_interface[c2746bee48761670]::util::run_in_thread_pool_with_globals<rustc_interface[c2746bee48761670]::interface::run_compiler<core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>, rustc_driver_impl[65af58b05c4f91ef]::run_compiler::{closure#0}>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[30be359c16b30868]::result::Result<(), rustc_span[467c297c964200f6]::ErrorGuaranteed>>::{closure#1} as core[30be359c16b30868]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7ff511262735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h99757397e7c4fa77
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/alloc/src/boxed.rs:2015:9
  45:     0x7ff511262735 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7e0e3d311e6447da
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/alloc/src/boxed.rs:2015:9
  46:     0x7ff511262735 - std::sys::pal::unix::thread::Thread::new::thread_start::h0eb0f22e3002fa19
                               at /rustc/af88f7db51f6f2a1472f9279d7c7e7c822afff77/library/std/src/sys/pal/unix/thread.rs:108:17
  47:     0x7ff50b0aa9eb - <unknown>
  48:     0x7ff50b12e7cc - <unknown>
  49:                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: rustc 1.78.0-nightly (af88f7db5 2024-02-08) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [mir_const] preparing `main::{closure#0}::{closure#0}` for borrow checking
#1 [mir_promoted] promoting constants in MIR for `main::{closure#0}::{closure#0}`
#2 [mir_borrowck] borrow-checking `main::{closure#0}::{closure#0}`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

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

Metadata

Metadata

Labels

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