Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when using async block form of async closure #121306

Closed
Skepfyr opened this issue Feb 19, 2024 · 1 comment · Fixed by #121350
Closed

ICE when using async block form of async closure #121306

Skepfyr opened this issue Feb 19, 2024 · 1 comment · Fixed by #121350
Assignees
Labels
C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Skepfyr
Copy link
Contributor

Skepfyr commented Feb 19, 2024

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)

@Skepfyr Skepfyr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 19, 2024
@jieyouxu jieyouxu added F-async_closure `#![feature(async_closure)]` requires-nightly This issue requires a nightly compiler in some way. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 19, 2024
@GrigorenkoPV
Copy link
Contributor

Regression in 757b8ef (#120712)

@compiler-errors compiler-errors self-assigned this Feb 20, 2024
@bors bors closed this as completed in 433180e Feb 21, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 21, 2024
Rollup merge of rust-lang#121350 - compiler-errors:resolve, r=oli-obk

Fix stray trait mismatch in `resolve_associated_item` for `AsyncFn`

Copy-paste error meant that we were calling `fn_trait_kind_from_def_id` instead of `async_fn_trait_kind_from_def_id`. But turns out we don't even need to do that, since we already matched the trait def id above.

Fixes rust-lang#121306

r? oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants