Skip to content

ICE when using async block form of async closure #121306

Closed
@Skepfyr

Description

@Skepfyr

Code

#![feature(async_closure)]

#[allow(unused_must_use)]
fn foo(f: impl async FnOnce()) {
    f();
}

pub fn main() {
    foo(|| async move {});
}

Importantly note that the closure passed to foo is || async move {}; async move || {} does not ICE.

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (2bf78d12d 2024-02-18)
binary: rustc
commit-hash: 2bf78d12d33ae02d10010309a0d85dd04e7cff72
commit-date: 2024-02-18
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Error output

thread 'rustc' panicked at compiler/rustc_ty_utils/src/instance.rs:327:90:
called `Option::unwrap()` on a `None` value

[...]

query stack during panic:
#0 [resolve_instance] resolving instance `<{closure@src/lib.rs:9:10: 9:12} as core::ops::async_function::AsyncFnOnce<()>>::async_call_once`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
#2 [exported_symbols] collecting exported symbols for crate `0`
end of query stack
Backtrace

thread 'rustc' panicked at compiler/rustc_ty_utils/src/instance.rs:327:90:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2bf78d12d33ae02d10010309a0d85dd04e7cff72/library/std/src/panicking.rs:648:5
   1: core::panicking::panic_fmt
             at /rustc/2bf78d12d33ae02d10010309a0d85dd04e7cff72/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/2bf78d12d33ae02d10010309a0d85dd04e7cff72/library/core/src/panicking.rs:144:5
   3: core::option::unwrap_failed
             at /rustc/2bf78d12d33ae02d10010309a0d85dd04e7cff72/library/core/src/option.rs:1983:5
   4: rustc_ty_utils::instance::resolve_instance
      [... omitted 1 frame ...]
   5: <rustc_middle::ty::instance::Instance>::expect_resolve
   6: rustc_monomorphize::collector::collect_items_rec::{closure#0}
   7: rustc_monomorphize::collector::collect_items_rec
   8: rustc_monomorphize::collector::collect_items_rec
   9: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  10: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
      [... omitted 2 frames ...]
  11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 16]>>>
  12: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
  13: rustc_metadata::rmeta::encoder::encode_metadata
  14: rustc_metadata::fs::encode_and_write_metadata
  15: rustc_interface::passes::start_codegen
  16: <rustc_interface::queries::Queries>::codegen_and_build_linker
  17: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

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 attach the file at `/home/jpr/ice/rustc-ice-2024-02-19T14_48_02-1138692.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=lld

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolve_instance] resolving instance `<{closure@src/lib.rs:9:10: 9:12} as core::ops::async_function::AsyncFnOnce<()>>::async_call_once`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
#2 [exported_symbols] collecting exported symbols for crate `0`
end of query stack
error: could not compile `ice` (lib)

Metadata

Metadata

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.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions