Skip to content
New issue

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

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

Already on GitHub? # to your account

ICE from trying to use an AsyncFnOnce<()> #137456

Closed
theemathas opened this issue Feb 23, 2025 · 1 comment
Closed

ICE from trying to use an AsyncFnOnce<()> #137456

theemathas opened this issue Feb 23, 2025 · 1 comment
Labels
C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` F-unboxed_closures `#![feature(unboxed_closures)]` 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.

Comments

@theemathas
Copy link
Contributor

Code

fn hello() -> impl AsyncFnOnce<()> {
    async || {}
}

fn require_send(_: impl Send) {}

fn main() {
    require_send(hello()());
}

Discovered by storycraft on the rust community discord.

Meta

Reproducible on the playground with stable rust 1.85.0, and nightly rust 1.87.0-nightly (2025-02-22 46420c96070b4c4bd824)

Error output

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
 --> src/main.rs:1:20
  |
1 | fn hello() -> impl AsyncFnOnce<()> {
  |                    ^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `AsyncFnOnce() -> ()`
  |
  = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
  = note: this compiler was built on 2025-02-22; consider upgrading it if it is out of date


thread 'rustc' panicked at compiler/rustc_middle/src/ty/generics.rs:310:14:
range end index 2 out of range for slice of length 1
stack backtrace:
   0:     0x72063af7da64 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb804b098a6980129
   1:     0x72063b6162ec - core::fmt::write::hdffc4a0668332a77
   2:     0x72063c6652d1 - std::io::Write::write_fmt::h158ff5518beb63ca
   3:     0x72063af7d8c2 - std::sys::backtrace::BacktraceLock::print::hea45f2c00969e919
   4:     0x72063af800ce - std::panicking::default_hook::{{closure}}::he9ac99c7ed13ae02
   5:     0x72063af7fca4 - std::panicking::default_hook::hc618b7eb019b3739
   6:     0x72063a0dd467 - std[b662901c3b9e4943]::panicking::update_hook::<alloc[c0817592b09a73e2]::boxed::Box<rustc_driver_impl[b70a0469a68d859d]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x72063af80943 - std::panicking::rust_panic_with_hook::hf14a914ad1da3f89
   8:     0x72063af8063a - std::panicking::begin_panic_handler::{{closure}}::h2bfbab6ac2361e6d
   9:     0x72063af7df39 - std::sys::backtrace::__rust_end_short_backtrace::h922c1637fa07a1b1
  10:     0x72063af802fd - rust_begin_unwind
  11:     0x720637c3ebc0 - core::panicking::panic_fmt::had3d135c9a0675d5
  12:     0x720639b15d77 - core::slice::index::slice_end_index_len_fail::do_panic::runtime::h37871641e9cb14d7
  13:     0x72063926e1ba - core::slice::index::slice_end_index_len_fail::h9c27a4e11a8c90c4
  14:     0x72063d2280bc - <rustc_middle[91360d98b3108f6b]::ty::generics::Generics>::own_args_no_defaults.cold
  15:     0x72063a6cccc2 - <rustc_middle[91360d98b3108f6b]::ty::print::pretty::FmtPrinter as rustc_middle[91360d98b3108f6b]::ty::print::pretty::PrettyPrinter>::pretty_print_opaque_impl_type
  16:     0x72063c68069f - <rustc_middle[91360d98b3108f6b]::ty::print::pretty::FmtPrinter as rustc_middle[91360d98b3108f6b]::ty::print::pretty::PrettyPrinter>::pretty_print_type
  17:     0x72063c67d758 - <rustc_middle[91360d98b3108f6b]::ty::print::pretty::FmtPrinter as rustc_middle[91360d98b3108f6b]::ty::print::Printer>::path_qualified
  18:     0x72063c67dd0f - <rustc_middle[91360d98b3108f6b]::ty::print::pretty::FmtPrinter as rustc_middle[91360d98b3108f6b]::ty::print::Printer>::print_def_path
  19:     0x72063c67ecfb - <rustc_middle[91360d98b3108f6b]::ty::print::pretty::FmtPrinter as rustc_middle[91360d98b3108f6b]::ty::print::pretty::PrettyPrinter>::pretty_print_type
  20:     0x72063c67cafe - <rustc_middle[91360d98b3108f6b]::ty::Ty as core[ebd7bf060a5fb430]::fmt::Display>::fmt
  21:     0x72063adce25e - <rustc_trait_selection[538bb8f6a49e4bff]::error_reporting::TypeErrCtxt>::on_unimplemented_note
  22:     0x72063adb23b9 - <rustc_trait_selection[538bb8f6a49e4bff]::error_reporting::TypeErrCtxt>::report_selection_error
  23:     0x72063ae068fc - <rustc_trait_selection[538bb8f6a49e4bff]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  24:     0x72063b8d349a - <rustc_hir_typeck[dbb34b65d893a3d7]::fn_ctxt::FnCtxt>::confirm_builtin_call
  25:     0x72063c43983c - <rustc_hir_typeck[dbb34b65d893a3d7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x72063c4329f4 - <rustc_hir_typeck[dbb34b65d893a3d7]::fn_ctxt::FnCtxt>::check_expr_block
  27:     0x72063c43a4e8 - <rustc_hir_typeck[dbb34b65d893a3d7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x72063bbe14a0 - rustc_hir_typeck[dbb34b65d893a3d7]::check::check_fn
  29:     0x72063bbea1c7 - rustc_hir_typeck[dbb34b65d893a3d7]::typeck_with_inspect::{closure#0}
  30:     0x72063bbe8288 - rustc_query_impl[eec7f452c89f9396]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[eec7f452c89f9396]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[91360d98b3108f6b]::query::erase::Erased<[u8; 8usize]>>
  31:     0x72063b9154cc - rustc_query_system[8fc675744f0966a]::query::plumbing::try_execute_query::<rustc_query_impl[eec7f452c89f9396]::DynamicConfig<rustc_data_structures[1ff0371f1e3af62]::vec_cache::VecCache<rustc_span[85b80dde5084fad5]::def_id::LocalDefId, rustc_middle[91360d98b3108f6b]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[8fc675744f0966a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[eec7f452c89f9396]::plumbing::QueryCtxt, false>
  32:     0x72063b913f9e - rustc_query_impl[eec7f452c89f9396]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  33:     0x72063b913c41 - <rustc_middle[91360d98b3108f6b]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[edbb94e8546d710b]::check_crate::{closure#3}>::{closure#0}
  34:     0x72063b9132c9 - rustc_hir_analysis[edbb94e8546d710b]::check_crate
  35:     0x72063b9c18dc - rustc_interface[e01acbff89da6aa1]::passes::run_required_analyses
  36:     0x72063c66127a - rustc_interface[e01acbff89da6aa1]::passes::analysis
  37:     0x72063c661259 - rustc_query_impl[eec7f452c89f9396]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[eec7f452c89f9396]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[91360d98b3108f6b]::query::erase::Erased<[u8; 0usize]>>
  38:     0x72063c6e084b - rustc_query_system[8fc675744f0966a]::query::plumbing::try_execute_query::<rustc_query_impl[eec7f452c89f9396]::DynamicConfig<rustc_query_system[8fc675744f0966a]::query::caches::SingleCache<rustc_middle[91360d98b3108f6b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[eec7f452c89f9396]::plumbing::QueryCtxt, false>
  39:     0x72063c6e0539 - rustc_query_impl[eec7f452c89f9396]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x72063c73983c - rustc_interface[e01acbff89da6aa1]::passes::create_and_enter_global_ctxt::<core[ebd7bf060a5fb430]::option::Option<rustc_interface[e01acbff89da6aa1]::queries::Linker>, rustc_driver_impl[b70a0469a68d859d]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  41:     0x72063c72d120 - rustc_interface[e01acbff89da6aa1]::interface::run_compiler::<(), rustc_driver_impl[b70a0469a68d859d]::run_compiler::{closure#0}>::{closure#1}
  42:     0x72063c57919c - std[b662901c3b9e4943]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e01acbff89da6aa1]::util::run_in_thread_with_globals<rustc_interface[e01acbff89da6aa1]::util::run_in_thread_pool_with_globals<rustc_interface[e01acbff89da6aa1]::interface::run_compiler<(), rustc_driver_impl[b70a0469a68d859d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  43:     0x72063c5795c0 - <<std[b662901c3b9e4943]::thread::Builder>::spawn_unchecked_<rustc_interface[e01acbff89da6aa1]::util::run_in_thread_with_globals<rustc_interface[e01acbff89da6aa1]::util::run_in_thread_pool_with_globals<rustc_interface[e01acbff89da6aa1]::interface::run_compiler<(), rustc_driver_impl[b70a0469a68d859d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ebd7bf060a5fb430]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x72063c579fab - std::sys::pal::unix::thread::Thread::new::thread_start::h516071c50e37afd1
  45:     0x72063dc45a94 - <unknown>
  46:     0x72063dcd2a34 - clone
  47:                0x0 - <unknown>

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 make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2025-02-23T04_15_10-21.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0658`.

@rustbot labels +F-async_closure +F-unboxed_closures

@theemathas theemathas 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 23, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-async_closure `#![feature(async_closure)]` F-unboxed_closures `#![feature(unboxed_closures)]` labels Feb 23, 2025
@compiler-errors
Copy link
Member

Duplicate of #133597

@compiler-errors compiler-errors marked this as a duplicate of #133597 Feb 23, 2025
jhpratt added a commit to jhpratt/rust that referenced this issue Feb 23, 2025
Fix missing self subst when rendering `impl Fn*<T>` with no output type

r? `@fmease` or reassign

Fixes rust-lang#133597
cc rust-lang#137456
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 23, 2025
Rollup merge of rust-lang#137458 - compiler-errors:render-fn, r=fmease

Fix missing self subst when rendering `impl Fn*<T>` with no output type

r? `@fmease` or reassign

Fixes rust-lang#133597
cc rust-lang#137456
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` F-unboxed_closures `#![feature(unboxed_closures)]` 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.
Projects
None yet
Development

No branches or pull requests

4 participants