ICE:Expected to find a suitable `Fn`/`FnMut`/`FnOnce` implementation for ..
Open
Nobody has claimed this yet.
C-bug
I-ICE
S-has-mcve
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
trait Trait {
type Assoc;
}
fn foo<F,T>(mut f: F) -> i32
where F: FnMut(<T as Trait>::Assoc) -> i32 {
(|x| f(x))(foo::<F, T>(f))
}
fn main() {}
Meta
rustc --version --verbose:
rustc 1.92.0-nightly (a9d0a6f15 2025-09-16)
binary: rustc
commit-hash: a9d0a6f15533a364816c4d81e2192009ef601d33
commit-date: 2025-09-16
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1
Error output
error[E0277]: the trait bound `T: Trait` is not satisfied
--> <source>:5:1
|
5 | / fn foo<F,T>(mut f: F) -> i32
6 | | where F: FnMut(<T as Trait>::Assoc) -> i32 {
| |__________________________________________^ the trait `Trait` is not implemented for `T`
|
help: consider further restricting type parameter `T` with trait `Trait`
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32, T: Trait {
| ++++++++++
error[E0277]: the trait bound `T: Trait` is not satisfied
--> <source>:6:10
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
|
help: consider further restricting type parameter `T` with trait `Trait`
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32, T: Trait {
| ++++++++++
error[E0277]: the trait bound `T: Trait` is not satisfied
--> <source>:7:10
|
7 | (|x| f(x))(foo::<F, T>(f))
| ^^^^ the trait `Trait` is not implemented for `T`
|
help: consider further restricting type parameter `T` with trait `Trait`
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32, T: Trait {
| ++++++++++
error[E0277]: the trait bound `T: Trait` is not satisfied
--> <source>:7:7
|
7 | (|x| f(x))(foo::<F, T>(f))
| ^ the trait `Trait` is not implemented for `T`
|
= note: all function arguments must have a statically known size
= help: unsized fn params are gated as an unstable feature
help: consider further restricting type parameter `T` with trait `Trait`
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32, T: Trait {
| ++++++++++
error[E0277]: the trait bound `T: Trait` is not satisfied
--> <source>:7:16
|
7 | (|x| f(x))(foo::<F, T>(f))
| ^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
|
help: consider further restricting type parameter `T` with trait `Trait`
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32, T: Trait {
| ++++++++++
error[E0308]: mismatched types
--> <source>:7:16
|
7 | (|x| f(x))(foo::<F, T>(f))
| ---------- ^^^^^^^^^^^^^^ expected associated type, found `i32`
| |
| arguments to this function are incorrect
|
= note: expected associated type `<T as Trait>::Assoc`
found type `i32`
= help: consider constraining the associated type `<T as Trait>::Assoc` to `i32` or calling a method that returns `<T as Trait>::Assoc`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: closure parameter defined here
--> <source>:7:7
|
7 | (|x| f(x))(foo::<F, T>(f))
| ^
error[E0277]: the trait bound `T: Trait` is not satisfied
--> <source>:7:6
|
7 | (|x| f(x))(foo::<F, T>(f))
| ^^^ the trait `Trait` is not implemented for `T`
|
help: consider further restricting type parameter `T` with trait `Trait`
|
6 | where F: FnMut(<T as Trait>::Assoc) -> i32, T: Trait {
| ++++++++++
error: internal compiler error: compiler/rustc_hir_typeck/src/callee.rs:1032:17: Expected to find a suitable `Fn`/`FnMut`/`FnOnce` implementation for `{closure@<source>:7:6: 7:9}`
--> <source>:7:5
|
7 | (|x| f(x))(foo::<F, T>(f))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' (3) panicked at compiler/rustc_hir_typeck/src/callee.rs:1032:17:
Box<dyn Any>
Backtrace
stack backtrace:
0: 0x7704d8c05953 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1d9a860939142303
1: 0x7704d9401fc4 - core::fmt::write::h4cde2f6e6eca889f
2: 0x7704d8bba5f1 - std::io::Write::write_fmt::hbbb02a45894db6e0
3: 0x7704d8bcb5d2 - std::sys::backtrace::BacktraceLock::print::hfcdaff63564fa703
4: 0x7704d8bd1539 - std::panicking::default_hook::{{closure}}::hcc588fdbd9e0eddf
5: 0x7704d8bd1063 - std::panicking::default_hook::h21841b6cba7fa436
6: 0x7704d7bf5bd7 - std[6c96415bc1a38016]::panicking::update_hook::<alloc[c6e2df4d00e1f0b6]::boxed::Box<rustc_driver_impl[459800387efcc559]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7704d8bd195f - std::panicking::panic_with_hook::hedf05123aa8b61bb
8: 0x7704d7c32471 - std[6c96415bc1a38016]::panicking::begin_panic::<rustc_errors[af568b6d67acca2f]::ExplicitBug>::{closure#0}
9: 0x7704d7c25c86 - std[6c96415bc1a38016]::sys::backtrace::__rust_end_short_backtrace::<std[6c96415bc1a38016]::panicking::begin_panic<rustc_errors[af568b6d67acca2f]::ExplicitBug>::{closure#0}, !>
10: 0x7704d7c23729 - std[6c96415bc1a38016]::panicking::begin_panic::<rustc_errors[af568b6d67acca2f]::ExplicitBug>
11: 0x7704d7c3db61 - <rustc_errors[af568b6d67acca2f]::diagnostic::BugAbort as rustc_errors[af568b6d67acca2f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7704d81aaa2c - <rustc_errors[af568b6d67acca2f]::DiagCtxtHandle>::span_bug::<rustc_span[9408016a182fdcc0]::span_encoding::Span, alloc[c6e2df4d00e1f0b6]::string::String>
13: 0x7704d81cfd97 - rustc_middle[e11099e36afb5411]::util::bug::opt_span_bug_fmt::<rustc_span[9408016a182fdcc0]::span_encoding::Span>::{closure#0}
14: 0x7704d81cff7a - rustc_middle[e11099e36afb5411]::ty::context::tls::with_opt::<rustc_middle[e11099e36afb5411]::util::bug::opt_span_bug_fmt<rustc_span[9408016a182fdcc0]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x7704d81beb4b - rustc_middle[e11099e36afb5411]::ty::context::tls::with_context_opt::<rustc_middle[e11099e36afb5411]::ty::context::tls::with_opt<rustc_middle[e11099e36afb5411]::util::bug::opt_span_bug_fmt<rustc_span[9408016a182fdcc0]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x7704d6210d67 - rustc_middle[e11099e36afb5411]::util::bug::span_bug_fmt::<rustc_span[9408016a182fdcc0]::span_encoding::Span>
17: 0x7704da2014c4 - <rustc_hir_typeck[ec5df76106ecc9bb]::fn_ctxt::FnCtxt>::analyze_closure
18: 0x7704d986460a - <rustc_hir_typeck[ec5df76106ecc9bb]::upvar::InferBorrowKindVisitor as rustc_hir[f64a1fb3a7caff8d]::intravisit::Visitor>::visit_expr
19: 0x7704d9864780 - <rustc_hir_typeck[ec5df76106ecc9bb]::upvar::InferBorrowKindVisitor as rustc_hir[f64a1fb3a7caff8d]::intravisit::Visitor>::visit_expr
20: 0x7704d98681b1 - rustc_hir_typeck[ec5df76106ecc9bb]::typeck_with_inspect::{closure#0}
21: 0x7704d98662b6 - rustc_query_impl[8ceca73aa722394f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ceca73aa722394f]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 8usize]>>
22: 0x7704d95e74c4 - rustc_query_system[44f2cb83942a7389]::query::plumbing::try_execute_query::<rustc_query_impl[8ceca73aa722394f]::DynamicConfig<rustc_data_structures[e568e5fb65a8620a]::vec_cache::VecCache<rustc_span[9408016a182fdcc0]::def_id::LocalDefId, rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[44f2cb83942a7389]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8ceca73aa722394f]::plumbing::QueryCtxt, false>
23: 0x7704d95e6e49 - rustc_query_impl[8ceca73aa722394f]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
24: 0x7704d9ec96c5 - <rustc_middle[e11099e36afb5411]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[1618d3df19afa2f8]::check_crate::{closure#2}>::{closure#0}
25: 0x7704d9ec8a4d - rustc_hir_analysis[1618d3df19afa2f8]::check_crate
26: 0x7704d95e8bb0 - rustc_interface[f4ad0248271d71d8]::passes::analysis
27: 0x7704d95e886d - rustc_query_impl[8ceca73aa722394f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ceca73aa722394f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 0usize]>>
28: 0x7704da465526 - rustc_query_system[44f2cb83942a7389]::query::plumbing::try_execute_query::<rustc_query_impl[8ceca73aa722394f]::DynamicConfig<rustc_query_system[44f2cb83942a7389]::query::caches::SingleCache<rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8ceca73aa722394f]::plumbing::QueryCtxt, false>
29: 0x7704da46517c - rustc_query_impl[8ceca73aa722394f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
30: 0x7704da672d4f - rustc_interface[f4ad0248271d71d8]::passes::create_and_enter_global_ctxt::<core[88dcab6addd45e6c]::option::Option<rustc_interface[f4ad0248271d71d8]::queries::Linker>, rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
31: 0x7704da5e96be - rustc_interface[f4ad0248271d71d8]::interface::run_compiler::<(), rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}>::{closure#1}
32: 0x7704da5482f8 - std[6c96415bc1a38016]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_with_globals<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_pool_with_globals<rustc_interface[f4ad0248271d71d8]::interface::run_compiler<(), rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
33: 0x7704da547fdc - <<std[6c96415bc1a38016]::thread::Builder>::spawn_unchecked_<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_with_globals<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_pool_with_globals<rustc_interface[f4ad0248271d71d8]::interface::run_compiler<(), rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[88dcab6addd45e6c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x7704da54e68d - std::sys::thread::unix::Thread::new::thread_start::hb28ad79a6a69b48c
35: 0x7704d3c94ac3 - <unknown>
36: 0x7704d3d26850 - <unknown>
37: 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: please make sure that you have updated to the latest nightly
note: please attach the file at `/app/rustc-ice-2025-09-19T08_13_00-1.txt` to your bug report
note: compiler flags: -C debuginfo=2 --crate-type bin -C linker=/opt/compiler-explorer/gcc-15.2.0/bin/gcc
query stack during panic:
#0 [typeck] type-checking `foo`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the minimal Rust example with the reported nightly compiler and inspect the type-checking query for foo. The panic is reported at compiler/rustc_hir_typeck/src/callee.rs:1032, in closure analysis; done means the example produces diagnostics without an internal compiler error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100