rustc ICEs, "expected a Fn(u64)
closure, found F
" #125099
Open
Description
I am not sure whether it is related to
AsyncAssociated-types usage in that context
My own experiments shown that by removing Future
usage it's possible to get rid of ICE
, however, that's not necessarily identifies the problem
It is related to diagnostic as shown by @lqd - #125099 (comment)
Also code was a lot shortened - #125099 (comment)
Original code is still available at playground for history
- https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c52b040dfc58e830766b99d674d3b02c
- Removing
Future
s usage eliminates ICE: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=81a36dbd18a3e21095514160b783ae95
Code
pub trait ContFn<T>: Fn(T) -> Self::Future {
type Future;
}
impl<T, F> ContFn<T> for F
where
F: Fn(T),
{
type Future = ();
}
pub trait SeqHandler {
type Requires;
fn process<F: ContFn<Self::Requires>>() -> impl Sized;
}
pub struct ConvertToU64;
impl SeqHandler for ConvertToU64 {
type Requires = u64;
fn process<F: ContFn<Self::Requires>>() -> impl Sized {}
}
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.80.0-nightly (ef0027897 2024-05-12)
binary: rustc
commit-hash: ef0027897d2e9014766fb47dce9ddbb925d2f540
commit-date: 2024-05-12
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Error output
error[E0277]: expected a `Fn(u64)` closure, found `F`
--> src/main.rs:19:48
|
19 | fn process<F: ContFn<Self::Requires>>() -> impl Sized {}
| ^^^^^^^^^^ expected an `Fn(u64)` closure, found `F`
|
= note: expected a closure with arguments `(<ConvertToU64 as SeqHandler>::Requires,)`
found a closure with arguments `(u64,)`
note: required for `F` to implement `ContFn<u64>`
--> src/main.rs:4:12
|
4 | impl<T, F> ContFn<T> for F
| ^^^^^^^^^ ^
5 | where
6 | F: Fn(T),
| ----- unsatisfied trait bound introduced here
Backtrace
thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:1657:13:
Box<dyn Any>
stack backtrace:
0: 0x7f552970f035 - std::backtrace_rs::backtrace::libunwind::trace::h83c0eb53992f6f11
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x7f552970f035 - std::backtrace_rs::backtrace::trace_unsynchronized::hd28c2b35fda3e21e
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f552970f035 - std::sys_common::backtrace::_print_fmt::hf2041091d6875033
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f552970f035 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h071af91c4208ccf0
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f552975e29b - core::fmt::rt::Argument::fmt::hbbac3246d92cc2c5
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/core/src/fmt/rt.rs:165:63
5: 0x7f552975e29b - core::fmt::write::hfbbdbbaa8a5636f0
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/core/src/fmt/mod.rs:1157:21
6: 0x7f5529703bdf - std::io::Write::write_fmt::h4ed2a84aeff13252
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/io/mod.rs:1832:15
7: 0x7f552970ee0e - std::sys_common::backtrace::_print::h6e9434dab4d40a6f
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f552970ee0e - std::sys_common::backtrace::print::h05c5bdf93ac2b0b3
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f5529711779 - std::panicking::default_hook::{{closure}}::h14d287fc1f176f42
10: 0x7f55297114bd - std::panicking::default_hook::hb73c741e3f264f50
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/panicking.rs:298:9
11: 0x7f552c671236 - std[d671f4cd4b6e9ae0]::panicking::update_hook::<alloc[89249b282a72629c]::boxed::Box<rustc_driver_impl[e938c283237ebd1d]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f5529711e76 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h68f37c64f31b57a5
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/alloc/src/boxed.rs:2036:9
13: 0x7f5529711e76 - std::panicking::rust_panic_with_hook::h78c61ae4c0782913
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/panicking.rs:799:13
14: 0x7f552c69e524 - std[d671f4cd4b6e9ae0]::panicking::begin_panic::<rustc_errors[c9503766cee81917]::ExplicitBug>::{closure#0}
15: 0x7f552c69aed6 - std[d671f4cd4b6e9ae0]::sys_common::backtrace::__rust_end_short_backtrace::<std[d671f4cd4b6e9ae0]::panicking::begin_panic<rustc_errors[c9503766cee81917]::ExplicitBug>::{closure#0}, !>
16: 0x7f552c6965e6 - std[d671f4cd4b6e9ae0]::panicking::begin_panic::<rustc_errors[c9503766cee81917]::ExplicitBug>
17: 0x7f552c6a79b1 - <rustc_errors[c9503766cee81917]::diagnostic::BugAbort as rustc_errors[c9503766cee81917]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x7f552cb2a32c - rustc_middle[4faf5b3238586354]::util::bug::opt_span_bug_fmt::<rustc_span[843dd1dc3d395857]::span_encoding::Span>::{closure#0}
19: 0x7f552cb10c5a - rustc_middle[4faf5b3238586354]::ty::context::tls::with_opt::<rustc_middle[4faf5b3238586354]::util::bug::opt_span_bug_fmt<rustc_span[843dd1dc3d395857]::span_encoding::Span>::{closure#0}, !>::{closure#0}
20: 0x7f552cb10afb - rustc_middle[4faf5b3238586354]::ty::context::tls::with_context_opt::<rustc_middle[4faf5b3238586354]::ty::context::tls::with_opt<rustc_middle[4faf5b3238586354]::util::bug::opt_span_bug_fmt<rustc_span[843dd1dc3d395857]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
21: 0x7f552aabbd00 - rustc_middle[4faf5b3238586354]::util::bug::bug_fmt
22: 0x7f552ea19260 - <rustc_middle[4faf5b3238586354]::ty::context::TyCtxt>::item_name
23: 0x7f552d171cd6 - <rustc_infer[f3ee925b5e7b0699]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33b4cd29aa451938]::traits::error_reporting::suggestions::TypeErrCtxtExt>::note_obligation_cause_code::<rustc_span[843dd1dc3d395857]::ErrorGuaranteed, rustc_middle[4faf5b3238586354]::ty::sty::Binder<rustc_middle[4faf5b3238586354]::ty::predicate::TraitPredicate>>
24: 0x7f552d175fd3 - <rustc_infer[f3ee925b5e7b0699]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33b4cd29aa451938]::traits::error_reporting::suggestions::TypeErrCtxtExt>::note_obligation_cause_code::<rustc_span[843dd1dc3d395857]::ErrorGuaranteed, rustc_middle[4faf5b3238586354]::ty::predicate::Predicate>
25: 0x7f552d19558c - <rustc_infer[f3ee925b5e7b0699]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33b4cd29aa451938]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::note_obligation_cause
26: 0x7f552d186a59 - <rustc_infer[f3ee925b5e7b0699]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33b4cd29aa451938]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
27: 0x7f552d19a932 - <rustc_infer[f3ee925b5e7b0699]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33b4cd29aa451938]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
28: 0x7f552d1848e0 - <rustc_infer[f3ee925b5e7b0699]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[33b4cd29aa451938]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
29: 0x7f552e91c691 - rustc_hir_analysis[407458696a46a4ec]::check::check::check_impl_items_against_trait
30: 0x7f552df21798 - rustc_hir_analysis[407458696a46a4ec]::check::wfcheck::check_well_formed
31: 0x7f552df1fe53 - rustc_query_impl[e53a9462fee58497]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e53a9462fee58497]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4faf5b3238586354]::query::erase::Erased<[u8; 1usize]>>
32: 0x7f552df1f9f9 - rustc_query_system[81a33fca0f7b0460]::query::plumbing::try_execute_query::<rustc_query_impl[e53a9462fee58497]::DynamicConfig<rustc_query_system[81a33fca0f7b0460]::query::caches::VecCache<rustc_hir[c2c0e904be5802a4]::hir_id::OwnerId, rustc_middle[4faf5b3238586354]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e53a9462fee58497]::plumbing::QueryCtxt, false>
33: 0x7f552df1f7bf - rustc_query_impl[e53a9462fee58497]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
34: 0x7f552df1da89 - rustc_hir_analysis[407458696a46a4ec]::check::wfcheck::check_mod_type_wf
35: 0x7f552df1d927 - rustc_query_impl[e53a9462fee58497]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e53a9462fee58497]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4faf5b3238586354]::query::erase::Erased<[u8; 1usize]>>
36: 0x7f552e5e453a - rustc_query_system[81a33fca0f7b0460]::query::plumbing::try_execute_query::<rustc_query_impl[e53a9462fee58497]::DynamicConfig<rustc_query_system[81a33fca0f7b0460]::query::caches::DefaultCache<rustc_span[843dd1dc3d395857]::def_id::LocalModDefId, rustc_middle[4faf5b3238586354]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e53a9462fee58497]::plumbing::QueryCtxt, false>
37: 0x7f552e5e430b - rustc_query_impl[e53a9462fee58497]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
38: 0x7f552dcf489c - rustc_hir_analysis[407458696a46a4ec]::check_crate
39: 0x7f552e2ba1e0 - rustc_interface[889ca9ecceb763c3]::passes::analysis
40: 0x7f552e2b9be5 - rustc_query_impl[e53a9462fee58497]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e53a9462fee58497]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4faf5b3238586354]::query::erase::Erased<[u8; 1usize]>>
41: 0x7f552e6c1922 - rustc_query_system[81a33fca0f7b0460]::query::plumbing::try_execute_query::<rustc_query_impl[e53a9462fee58497]::DynamicConfig<rustc_query_system[81a33fca0f7b0460]::query::caches::SingleCache<rustc_middle[4faf5b3238586354]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e53a9462fee58497]::plumbing::QueryCtxt, false>
42: 0x7f552e6c1753 - rustc_query_impl[e53a9462fee58497]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
43: 0x7f552e549e09 - rustc_interface[889ca9ecceb763c3]::interface::run_compiler::<core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>, rustc_driver_impl[e938c283237ebd1d]::run_compiler::{closure#0}>::{closure#1}
44: 0x7f552e53994b - std[d671f4cd4b6e9ae0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[889ca9ecceb763c3]::util::run_in_thread_with_globals<rustc_interface[889ca9ecceb763c3]::interface::run_compiler<core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>, rustc_driver_impl[e938c283237ebd1d]::run_compiler::{closure#0}>::{closure#1}, core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>>
45: 0x7f552e539734 - <<std[d671f4cd4b6e9ae0]::thread::Builder>::spawn_unchecked_<rustc_interface[889ca9ecceb763c3]::util::run_in_thread_with_globals<rustc_interface[889ca9ecceb763c3]::interface::run_compiler<core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>, rustc_driver_impl[e938c283237ebd1d]::run_compiler::{closure#0}>::{closure#1}, core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[df047223aae5189a]::result::Result<(), rustc_span[843dd1dc3d395857]::ErrorGuaranteed>>::{closure#2} as core[df047223aae5189a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
46: 0x7f552971bcab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2c411cd68361b013
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/alloc/src/boxed.rs:2022:9
47: 0x7f552971bcab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h139d8161222f5c3a
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/alloc/src/boxed.rs:2022:9
48: 0x7f552971bcab - std::sys::pal::unix::thread::Thread::new::thread_start::h14ec8ded327b57eb
at /rustc/a26981974230110fa8fb15e1cf04d05b9a2103f9/library/std/src/sys/pal/unix/thread.rs:108:17
49: 0x7f5529629609 - start_thread
50: 0x7f552954c353 - clone
51: 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.79.0-beta.4 (a26981974 2024-05-10) running on x86_64-unknown-linux-gnu
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 [check_well_formed] checking that `<impl at src/main.rs:17:1: 17:33>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0277`.
Metadata
Assignees
Labels
Type
Projects
Status
Todo